Installation via Composer
composer require roboticsexpert/ticketit
Run migrations:
php artisan vendor:publish --provider="Ticketit\TicketitServiceProvider" --tag=migrations
php artisan migrate
Publish Assets & Config
php artisan vendor:publish --provider="Ticketit\TicketitServiceProvider" --tag=config
php artisan vendor:publish --provider="Ticketit\TicketitServiceProvider" --tag=public
php artisan vendor:publish --provider="Ticketit\TicketitServiceProvider" --tag=views
Add Routes
Include Ticketit routes in routes/web.php:
Route::middleware(['web', 'auth'])->group(function () {
require __DIR__.'/ticketit.php';
});
First Use Case
/tickets → Create a ticket with a subject, description, and optional attachments./tickets → Reply to tickets or update status.Ticket Creation & Management
subject, description, and priority.Ticketit\Ticket facade or inject Ticketit\Repositories\TicketRepository for programmatic access:
use Ticketit\Facades\Ticket;
$ticket = Ticket::create(['subject' => 'Issue', 'user_id' => auth()->id()]);
Auto-Assignment Logic
config/ticketit.php:
'departments' => [
'technical' => ['agents' => [1, 2]], // Agent IDs
'billing' => ['agents' => [3]],
],
queue_weight in config).Role-Based Permissions
user, agent, admin) via middleware or policy bindings:
// app/Providers/AuthServiceProvider.php
Gate::define('close-ticket', function ($user) {
return $user->role === 'admin' || $user->role === 'agent';
});
Localization & UI
config/ticketit.php:
'locale' => 'en', // or 'ar', 'de', etc.
resources/views/vendor/ticketit/.Admin Dashboard
/admin/tickets. Use the built-in stats graphs or extend with custom queries:
$recentTickets = Ticket::with('user', 'agent')->latest()->take(10)->get();
Attachments & Rich Text
storage/app/public/ticketit/attachments.Migration Conflicts
users table lacks role column, add it manually or extend the users table migration:
Schema::table('users', function (Blueprint $table) {
$table->string('role')->default('user');
});
Auto-Assignment Failures
departments and agents are properly configured in config/ticketit.php. Verify agent IDs exist in the users table.\Log::info('Departments config:', config('ticketit.departments'));
Permission Denied Errors
app/Http/Kernel.php for auth and role checks. Example:
Route::middleware(['auth', 'role:admin|agent'])->group(function () {
// Agent/admin routes
});
Localization Issues
php artisan vendor:publish --provider="Ticketit\TicketitServiceProvider" --tag=lang
resources/lang/vendor/ticketit.Attachment Paths
storage/app/public/ticketit/attachments is writable:
mkdir -p storage/app/public/ticketit/attachments
chmod -R 775 storage/app/public/ticketit
php artisan storage:link
Custom Ticket Fields
tickets table via a migration, then update the Ticket model:
protected $fillable = ['subject', 'description', 'user_id', 'custom_field'];
Event Listeners
TicketCreated) in EventServiceProvider:
protected $listen = [
'Ticketit\Events\TicketCreated' => [
'App\Listeners\SendTicketNotification',
],
];
API Integration
Route::middleware('auth:api')->get('/tickets', 'TicketController@index');
public function index() {
return TicketResource::collection(Ticket::where('user_id', auth()->id())->get());
}
Customizing Views
vendor/roboticsexpert/ticketit/resources/views to resources/views/vendor/ticketit.Testing
$ticket = factory(Ticketit\Ticket::class)->create(['user_id' => $user->id]);
$this->assertEquals('open', $ticket->status);
queue_weight in config/ticketit.php to balance agent workloads (lower = higher priority).role column in users table matches config/ticketit.roles (e.g., ['user', 'agent', 'admin']).ticketit.notifications in config/ticketit.php to enable/disable emails for ticket events.How can I help you explore Laravel packages today?