Installation
composer require yurapyzhyk/ticketit
php artisan vendor:publish --provider="YuraPyzyk\Ticketit\TicketitServiceProvider"
php artisan migrate
php artisan ticketit:install
php artisan ticketit:install to set up default roles (users, agents, admins) and seed initial data.Configure Routes
Add to routes/web.php:
Route::middleware(['auth'])->group(function () {
require __DIR__.'/ticketit.php';
});
First Ticket Creation
/tickets/create to open the ticket form.Admin Panel
Access /admin/tickets to manage tickets, agents, and departments.
Ticket Lifecycle
/tickets/{id}/reply)./admin/tickets/mark-as-read).Auto-Assignment Logic
config/ticketit.php:
'departments' => [
'technical' => ['agents' => ['agent1@example.com']],
'billing' => ['agents' => ['agent2@example.com']],
],
Localization
config/app.php (e.g., 'locale' => 'fr').resources/lang/vendor/ticketit.Permissions
auth:agent, auth:admin) to restrict routes:
Route::middleware(['auth:agent'])->group(function () {
Route::get('/agent/dashboard', 'AgentController@dashboard');
});
Customizing Views
resources/views/vendor/ticketit/.resources/views/vendor/ticketit/tickets/create.blade.php to your project.Extending Models
php artisan vendor:publish --tag=ticketit-migrations) to add custom fields to tickets or users tables.priority column to tickets table.Event Listeners
TicketCreated) in EventServiceProvider:
protected $listen = [
'YuraPyzyk\Ticketit\Events\TicketCreated' => [
'App\Listeners\SendTicketNotification',
],
];
API Integration (Optional)
Route::middleware('auth:api')->get('/tickets', 'TicketApiController@index');
Role Conflicts
php artisan ticketit:roles to check assignments.Auto-Assignment Failures
config/ticketit.php.users table with the agent role.ticketit_last_assigned_at timestamp in the future.Localization Caching
php artisan view:clear
File Uploads
laravel-filemanager. Ensure:
composer require unclead/laravel-filemanager).php artisan storage:link).Middleware Overrides
app/Http/Kernel.php:
'auth:agent' => \YuraPyzyk\Ticketit\Http\Middleware\AuthenticateAgent::class,
Database Seeding
php artisan migrate:fresh if you’ve manually added data (e.g., custom agents). Use --seed carefully:
php artisan migrate:fresh --seed # Resets everything!
Log Auto-Assignment
Add to config/ticketit.php:
'debug' => true, // Logs assignment logic to Laravel logs.
Check Queue Metrics Run this SQL to verify agent workloads:
SELECT user_id, COUNT(*) as ticket_count
FROM tickets
WHERE assigned_to IS NOT NULL
GROUP BY user_id;
Common Errors
can() checks in controllers.php artisan vendor:publish --tag=ticketit-lang
Custom Fields
tickets table via migrations, then extend the Ticket model:
public function getPriorityAttribute()
{
return $this->attributes['priority'] ?? 'medium';
}
Hooks for Business Logic
TicketitServiceProvider to bind interfaces:
$this->app->bind(
YuraPyzyk\Ticketit\Contracts\TicketAssigner::class,
App\Services\CustomTicketAssigner::class
);
Webhooks
// In EventServiceProvider
'YuraPyzyk\Ticketit\Events\TicketUpdated' => [
'App\Listeners\SlackNotification',
],
Testing
TicketitTestCase for unit tests:
use YuraPyzyk\Ticketit\Tests\TestCase;
class TicketTest extends TestCase {
public function testCreateTicket() { ... }
}
How can I help you explore Laravel packages today?