binshops/laravel-ticket
Helpdesk ticketing system for Laravel 5.1–10 that integrates with Laravel auth/users. Supports users, agents and admins; ticket creation, comments, status tracking and closing; auto agent assignment by department; admin dashboard, stats, localization and image uploads.
Installation
composer require binshops/laravel-ticket
php artisan vendor:publish --provider="Binshops\Ticket\TicketServiceProvider" --tag="migrations"
php artisan migrate
--tag="config") and views (--tag="views") if needed.Basic Configuration
.env for required settings (e.g., TICKET_DRIVER=database).config/ticket.php for default ticket settings (e.g., default_status, default_priority).First Use Case: Creating a Ticket
use Binshops\Ticket\Models\Ticket;
// Create a ticket for the authenticated user
$ticket = Ticket::create([
'title' => 'API Issue',
'description' => 'Endpoint /api/v1/users returns 500',
'priority' => 'high',
]);
php artisan ticket:install to set up default roles/permissions if needed.Ticket Creation & Assignment
ticket.store route (e.g., Route::post('/tickets', [TicketController::class, 'store'])).Ticket::create() or auth()->user()->tickets()->create() for user-specific tickets.Ticket::where(...)->update(['status' => 'resolved']) for status updates.Ticket Management
$ticket->attachments()->create(['path' => 'path/to/file.pdf']);
$ticket->comments()->create(['body' => 'Debugging...']);
Ticket::updateStatus('pending') or custom logic via events (TicketStatusUpdated).Search & Filtering
$tickets = Ticket::where('status', 'open')
->whereHas('comments', fn($q) => $q->where('body', 'like', '%debug%'))
->latest()
->get();
TicketResource (if published) for API responses.Automation
TicketCreated, TicketStatusUpdated, etc.
Event::listen(TicketStatusUpdated::class, function ($ticket) {
if ($ticket->status === 'resolved') {
// Send notification
}
});
SendTicketNotification after status changes.Custom Fields
Ticket model to add custom attributes:
class Ticket extends \Binshops\Ticket\Models\Ticket
{
protected $casts = [
'custom_field' => 'array',
];
}
Permission Issues
create_ticket, update_ticket, etc., permissions via can() or middleware.php artisan ticket:install.Attachment Handling
storage/app/public/ticket_attachments is writable.Storage::disk('public')->put() for custom upload logic.Database Conflicts
tickets table (configurable via table in config/ticket.php).Event Overrides
TicketCreated), ensure your listeners run after the package’s default logic.TicketCreated::dispatch($ticket) with Log::info() for debugging.DB::enableQueryLog()) to inspect ticket queries.php artisan db:seed --class=TicketTableSeeder (if provided) for testing.Custom Statuses/Priorities
config/ticket.php or use model events to validate custom values.API Endpoints
TicketController or create a dedicated API resource:
Route::apiResource('tickets', TicketApiController::class)->middleware('auth:api');
Notifications
TicketCreated notification with a custom channel (e.g., Slack):
class CustomTicketNotification extends Notification
{
public function via($notifiable)
{
return ['slack'];
}
}
Testing
TicketFactory (if available) or factories:
$ticket = Ticket::factory()->create(['status' => 'pending']);
Event::fake();
$ticket->update(['status' => 'resolved']);
Event::assertDispatched(TicketStatusUpdated::class);
How can I help you explore Laravel packages today?