Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Ticket Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation

    composer require binshops/laravel-ticket
    php artisan vendor:publish --provider="Binshops\Ticket\TicketServiceProvider" --tag="migrations"
    php artisan migrate
    
    • Publish config (--tag="config") and views (--tag="views") if needed.
  2. Basic Configuration

    • Review .env for required settings (e.g., TICKET_DRIVER=database).
    • Configure config/ticket.php for default ticket settings (e.g., default_status, default_priority).
  3. 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',
    ]);
    
    • Use php artisan ticket:install to set up default roles/permissions if needed.

Implementation Patterns

Core Workflows

  1. Ticket Creation & Assignment

    • Frontend: Use a form with ticket.store route (e.g., Route::post('/tickets', [TicketController::class, 'store'])).
    • Backend: Leverage Ticket::create() or auth()->user()->tickets()->create() for user-specific tickets.
    • Bulk Actions: Use Ticket::where(...)->update(['status' => 'resolved']) for status updates.
  2. Ticket Management

    • Attachments:
      $ticket->attachments()->create(['path' => 'path/to/file.pdf']);
      
    • Comments:
      $ticket->comments()->create(['body' => 'Debugging...']);
      
    • Status Transitions: Use Ticket::updateStatus('pending') or custom logic via events (TicketStatusUpdated).
  3. Search & Filtering

    • Query Builder:
      $tickets = Ticket::where('status', 'open')
          ->whereHas('comments', fn($q) => $q->where('body', 'like', '%debug%'))
          ->latest()
          ->get();
      
    • API Integration: Use TicketResource (if published) for API responses.
  4. Automation

    • Events: Listen to TicketCreated, TicketStatusUpdated, etc.
      Event::listen(TicketStatusUpdated::class, function ($ticket) {
          if ($ticket->status === 'resolved') {
              // Send notification
          }
      });
      
    • Queued Jobs: Dispatch SendTicketNotification after status changes.
  5. Custom Fields

    • Extend the Ticket model to add custom attributes:
      class Ticket extends \Binshops\Ticket\Models\Ticket
      {
          protected $casts = [
              'custom_field' => 'array',
          ];
      }
      

Gotchas and Tips

Pitfalls

  1. Permission Issues

    • Ensure users have create_ticket, update_ticket, etc., permissions via can() or middleware.
    • Default roles may not be published; check php artisan ticket:install.
  2. Attachment Handling

    • Verify storage/app/public/ticket_attachments is writable.
    • Use Storage::disk('public')->put() for custom upload logic.
  3. Database Conflicts

    • Avoid naming conflicts with existing tickets table (configurable via table in config/ticket.php).
  4. Event Overrides

    • If extending events (e.g., TicketCreated), ensure your listeners run after the package’s default logic.

Debugging Tips

  • Log Events: Use TicketCreated::dispatch($ticket) with Log::info() for debugging.
  • Query Logs: Enable Laravel’s query logging (DB::enableQueryLog()) to inspect ticket queries.
  • Seeds: Use php artisan db:seed --class=TicketTableSeeder (if provided) for testing.

Extension Points

  1. Custom Statuses/Priorities

    • Override config/ticket.php or use model events to validate custom values.
  2. API Endpoints

    • Extend TicketController or create a dedicated API resource:
      Route::apiResource('tickets', TicketApiController::class)->middleware('auth:api');
      
  3. Notifications

    • Replace TicketCreated notification with a custom channel (e.g., Slack):
      class CustomTicketNotification extends Notification
      {
          public function via($notifiable)
          {
              return ['slack'];
          }
      }
      
  4. Testing

    • Use TicketFactory (if available) or factories:
      $ticket = Ticket::factory()->create(['status' => 'pending']);
      
    • Mock events for unit tests:
      Event::fake();
      $ticket->update(['status' => 'resolved']);
      Event::assertDispatched(TicketStatusUpdated::class);
      
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor