dimpak/module-ticket
Laravel module for building a ticketing system. Provides structure and components for creating, managing, and tracking support tickets within a modular app, with configurable workflows and integration points for your existing Laravel project.
Installation Add the package via Composer:
composer require dimpak/module-ticket
Publish the configuration (if needed):
php artisan vendor:publish --provider="Dimpak\ModuleTicket\ModuleTicketServiceProvider"
Service Provider & Routes
Ensure the package’s service provider is registered in config/app.php under providers.
Run migrations (if applicable):
php artisan migrate
First Use Case Create a ticket via the facade or service:
use Dimpak\ModuleTicket\Facades\Ticket;
$ticket = Ticket::create([
'title' => 'Bug Report',
'description' => 'Issue with login form',
'priority' => 'high',
]);
Access tickets via the API or Blade:
$tickets = Ticket::all()->where('status', 'open');
Ticket Creation & Management
Ticket facade or inject Dimpak\ModuleTicket\Services\TicketService for programmatic control.$tickets = collect($csvData)->map(fn($row) => Ticket::create($row));
Status & Priority Handling
Leverage predefined statuses/priorities (e.g., open, closed, low, high) or extend via config:
config(['ticket.statuses' => ['pending', 'resolved']]);
Attachments & Metadata
Store files via Ticket::attach($ticketId, $filePath) or add custom metadata:
$ticket->metadata = ['source' => 'webform'];
$ticket->save();
Event-Driven Extensions
Listen to ticket.created, ticket.updated events for side effects (e.g., notifications):
event(new TicketCreated($ticket));
TicketResource (if provided) or build custom API routes:
Route::apiResource('tickets', 'TicketController')->middleware('auth:api');
Missing Migrations
If the package lacks migrations, manually create tables for tickets, ticket_attachments, etc., matching the expected schema.
Configuration Overrides
Ensure config/ticket.php is merged correctly—some settings may not apply if not explicitly defined.
Facade vs. Service
Prefer dependency injection (TicketService) over facades in testable code to avoid singleton pitfalls.
Attachment Limits
Validate file sizes/types in app/Providers/TicketServiceProvider if the package lacks built-in validation.
APP_DEBUG=true) to trace event dispatches.DB::enableQueryLog() to inspect SQL generated by the package’s Eloquent models.Custom Fields
Extend the Ticket model to add fields:
class Ticket extends \Dimpak\ModuleTicket\Models\Ticket {
protected $casts = ['custom_field' => 'boolean'];
}
Validation Rules
Override validation in app/Providers/TicketServiceProvider:
Ticket::extend(function ($service) {
$service->validator = function ($data) {
return Validator::make($data, ['title' => 'required|max:255']);
};
});
API Responses
Modify responses via middleware or override the TicketController:
public function show(Ticket $ticket) {
return response()->json($ticket->toArray() + ['custom_data' => true]);
}
How can I help you explore Laravel packages today?