aytaceminoglu/ticketit
Simple helpdesk ticket system for Laravel 5.1+ with users/agents/admin roles, configurable permissions, auto-assigning agents by department/queue, admin dashboard with stats, localization packs, and a lightweight editor for ticket descriptions and comments (image uploads).
Installation
composer require aytaceminoglu/ticketit
php artisan vendor:publish --provider="Ticketit\TicketitServiceProvider" --tag=config
php artisan migrate
Configuration
config/ticketit.php) and adjust settings like:
ticket_table (default: tickets)ticket_statuses (e.g., open, pending, closed)default_assignee (e.g., admin@domain.com)First Use Case
use Ticketit\Ticket;
$ticket = Ticket::create([
'title' => 'Test Ticket',
'description' => 'This is a test ticket.',
'user_id' => auth()->id(), // Laravel's default auth user
]);
http://ticketit.kordy.info/tickets for UI reference.Ticket Creation
Ticket model to create, update, or delete tickets:
// Create with assignee
$ticket = Ticket::create([
'title' => 'Bug Report',
'description' => 'Login fails on mobile.',
'user_id' => auth()->id(),
'assignee_id' => 1, // User ID of assignee
'status' => 'open',
]);
Ticket model’s rules() method.Status Transitions
status field to track workflow (e.g., open → pending → closed).$ticket->update(['status' => 'pending']);
Attachments
storage/app/public/ticket_attachments and save paths in the attachments JSON column:
$ticket->attachments = json_encode(['file1.pdf', 'file2.jpg']);
$ticket->save();
Notifications
TicketObserver or use Laravel’s notify() to send emails/Slack alerts on status changes:
use Ticketit\Observers\TicketObserver;
class CustomTicketObserver extends TicketObserver {
public function updated(Ticket $ticket) {
if ($ticket->wasChanged('status')) {
$ticket->user->notify(new TicketStatusUpdated($ticket));
}
}
}
API Integration
// routes/api.php
Route::apiResource('tickets', 'TicketController')->middleware('auth:api');
public function toArray($request) {
return [
'id' => $this->id,
'title' => $this->title,
'status' => $this->status,
'created_at' => $this->created_at->diffForHumans(),
];
}
Migration Conflicts
tickets table, ensure the ticketit migrations don’t overwrite your changes. Run php artisan vendor:publish --tag=migrations to customize them first.Auth Integration
users table. If using a custom auth system, override the user() relationship in the Ticket model:
public function user() {
return $this->belongsTo('App\Models\CustomUser');
}
Attachment Handling
attachments field is a JSON column. Ensure your database supports JSON (e.g., MySQL 5.7+). For older versions, use a text column and manually serialize/deserialize:
$attachments = json_decode($ticket->attachments, true);
Status Field
status field defaults to open. If you add custom statuses (e.g., escalated), update the ticket_statuses config array and ensure UI templates reflect these changes.Demo Dependency
http://ticketit.kordy.info/tickets may not match your local setup. Clone the repo’s resources/views for reference, but avoid copying vendor files directly.Log Observers
DB::enableQueryLog();
$ticket->update(['status' => 'closed']);
dd(DB::getQueryLog());
Check Config
config/ticketit.php for misconfigurations, especially:
ticket_table (must match your migrations).ticket_statuses (must include all used statuses).Artisan Commands
php artisan ticketit:clear-cache if templates or assets aren’t updating.Custom Fields
tickets table and extend the Ticket model:
protected $fillable = ['title', 'description', 'priority']; // Add 'priority'
Custom Views
resources/views/vendor/ticketit/ to customize the UI without modifying the package.API Filters
// Example: Filter tickets by status
$tickets = Ticket::whereIn('status', ['open', 'pending'])->get();
Webhooks
TicketObserver:
public function saved(Ticket $ticket) {
Http::post('https://your-webhook.com', [
'ticket_id' => $ticket->id,
'status' => $ticket->status,
]);
}
How can I help you explore Laravel packages today?