aagroup/support
Ticketit is a simple helpdesk ticket system for Laravel 5.1+ that integrates with Laravel auth. Supports users/agents/admins, ticket creation and comments, configurable permissions, auto agent assignment, admin dashboard with stats, localization, and image uploads.
Installation
composer require aagroup/support
php artisan vendor:publish --provider="AAGroup\Support\SupportServiceProvider" --tag=config
php artisan migrate
config/support.php is published and updated with your app’s database/queue settings.First Use Case: Creating a Ticket
use AAGroup\Support\Models\Ticket;
// Create a ticket for the authenticated user
$ticket = Ticket::create([
'subject' => 'API Integration Issue',
'body' => 'The endpoint /api/v1/users returns 500 errors.',
'user_id' => auth()->id(),
'status' => 'open', // or 'pending', 'resolved', etc.
]);
app/Models/Ticket.php (default model)routes/support.php (published routes for tickets, replies, etc.)resources/views/support/ (Blade templates for ticket listings/replies)Quick Integration with Auth
users table. No extra auth setup is needed unless extending roles (e.g., "Agent" vs. "Customer").Ticket Lifecycle Management
$ticket->update(['status' => 'resolved', 'resolved_at' => now()]);
$ticket->agents()->attach(auth()->id()); // For multi-agent support
$ticket->replies()->create([
'body' => 'Debugged the issue. Try this fix...',
'user_id' => auth()->id(),
]);
Querying Tickets
$openTickets = Ticket::where('status', 'open')
->where('user_id', auth()->id())
->with('replies')
->get();
$searchTerm = request('q');
$results = Ticket::where(function($query) use ($searchTerm) {
$query->where('subject', 'like', "%{$searchTerm}%")
->orWhere('body', 'like', "%{$searchTerm}%");
})->get();
Queue-Based Notifications
// Dispatch a new ticket event (extend the package’s events)
event(new \AAGroup\Support\Events\TicketCreated($ticket));
// In EventServiceProvider
protected $listen = [
\AAGroup\Support\Events\TicketCreated::class => [
\AAGroup\Support\Listeners\SendTicketNotification::class,
],
];
API Integration
Route::get('/api/tickets', function() {
return Ticket::with('replies', 'user')->get();
});
Extend the Model:
// Add custom fields (e.g., priority)
Schema::table('tickets', function(Blueprint $table) {
$table->string('priority')->default('medium');
});
Update Ticket model to cast/access the new field.
Customize Views:
Override published Blade templates in resources/views/support/ to match your app’s design.
Role-Based Access: Use Laravel’s Gate/Policy system to restrict ticket actions:
Gate::define('delete-ticket', function($user, $ticket) {
return $user->isAdmin() || $ticket->user_id === $user->id;
});
Testing: Use Laravel’s testing helpers:
$this->actingAs($user)
->post('/support/tickets', ['subject' => 'Test', 'body' => 'Body']);
Migration Conflicts
users table, the package’s migrations may fail. Solution: Manually adjust the tickets table migration to match your schema (e.g., add priority column).Event Dispatching
TicketCreated) but doesn’t include listeners by default. Tip: Publish the events/config first:
php artisan vendor:publish --provider="AAGroup\Support\SupportServiceProvider" --tag=events
Queue Stuck Jobs
failed_jobs table. Fix: Configure the queue driver in config/support.php (e.g., queue_connection => 'database').Overwriting Routes
routes/support.php) may conflict with your app’s routes. Tip: Prefix them:
Route::prefix('helpdesk')->group(function() {
// Published routes here
});
Log Ticket Events: Add a listener to log events:
// In app/Listeners/LogTicketEvents.php
public function handle($event) {
\Log::info('Ticket event', ['event' => $event->class, 'data' => $event->ticket]);
}
Check Middleware:
The package uses auth middleware. If routes fail, verify:
Route::middleware(['auth'])->group(function() {
// Support routes
});
Custom Statuses:
Extend the status field with a pivot table:
// Add to Ticket model
public function statuses() {
return $this->belongsToMany(Status::class);
}
Attachment Support:
Add a ticket_attachments table and relationship:
public function attachments() {
return $this->hasMany(TicketAttachment::class);
}
Webhooks: Dispatch events to external services:
// In TicketCreated listener
Http::post('https://your-webhook.com', ['ticket' => $ticket]);
API Rate Limiting:
Use Laravel’s throttle middleware for /api/tickets:
Route::middleware(['throttle:60,1'])->group(function() {
// API routes
});
How can I help you explore Laravel packages today?