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

Ticket System Laravel Package

cassianogf/ticket-system

Laravel package for a ticket system (work in progress). Intended to help manage support tickets and related workflows. Project is under construction and documentation is minimal, so expect incomplete features and APIs.

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation

    composer require cassianogf/ticket-system
    php artisan vendor:publish --provider="CassianoGF\TicketSystem\TicketSystemServiceProvider" --tag=config
    php artisan migrate
    
  2. Service Provider & Routes Ensure the package is registered in config/app.php under providers:

    CassianoGF\TicketSystem\TicketSystemServiceProvider::class,
    

    Publish routes (if not auto-loaded):

    php artisan vendor:publish --provider="CassianoGF\TicketSystem\TicketSystemServiceProvider" --tag=routes
    
  3. First Use Case

    • Create a ticket via Tinker or a controller:
      use CassianoGF\TicketSystem\Models\Ticket;
      $ticket = Ticket::create([
          'title' => 'Test Ticket',
          'description' => 'This is a test ticket.',
          'user_id' => auth()->id(), // Assuming Laravel auth is set up
      ]);
      
    • Access the demo at /tickets (if routes are published).

Implementation Patterns

Core Workflows

  1. Ticket Creation

    • Use the Ticket model to create, update, or delete tickets.
    • Example with validation:
      use Illuminate\Support\Facades\Validator;
      $validator = Validator::make($request->all(), [
          'title' => 'required|string|max:255',
          'description' => 'required|string',
      ]);
      if ($validator->fails()) return redirect()->back()->withErrors($validator);
      Ticket::create($validator->validated() + ['user_id' => auth()->id()]);
      
  2. Assigning Tickets

    • Assign tickets to users (e.g., support agents):
      $ticket->assignTo(User::find(1)); // Assign to user with ID 1
      
  3. Status Management

    • Update ticket status (e.g., open, pending, closed):
      $ticket->update(['status' => 'closed']);
      
  4. Integration with Auth

    • Use Laravel’s built-in auth to restrict access:
      // In a controller middleware
      public function __construct() {
          $this->middleware('auth');
      }
      

Common Use Cases

  • List Tickets for Current User
    $tickets = auth()->user()->tickets()->get();
    
  • Search Tickets
    $tickets = Ticket::where('title', 'like', '%test%')->get();
    
  • Customize Ticket Fields Extend the Ticket model or use accessors/mutators:
    public function getShortDescriptionAttribute() {
        return Str::limit($this->description, 100);
    }
    

Gotchas and Tips

Pitfalls

  1. Laravel Version Compatibility

    • The package was last updated in 2016 for Laravel 5.1+. Test thoroughly with newer Laravel versions (e.g., 8/9/10) or fork the repo for updates.
    • Fix: Use a compatibility layer (e.g., laravel-shift or manual polyfills) if needed.
  2. Missing Middleware

    • Routes may not be protected by default. Add middleware to restrict access:
      Route::middleware(['auth'])->group(function () {
          Route::resource('tickets', 'TicketController');
      });
      
  3. Demo Overrides

    • The demo at http://ticketit.kordy.info/tickets may not reflect your local setup. Always test locally first.
  4. Database Schema Assumptions

    • Assumes default Laravel users table. If using a custom auth system, update the user_id foreign key in migrations.

Debugging Tips

  • Check Published Config Review config/ticket-system.php for customizations (e.g., allowed statuses, default assignee).
  • Log Model Events Add observers or listeners to debug ticket lifecycle:
    Ticket::observe(TicketObserver::class);
    
  • Route Debugging Use php artisan route:list to verify published routes.

Extension Points

  1. Custom Ticket Fields Add columns to the tickets table and extend the model:

    // Migration
    Schema::table('tickets', function (Blueprint $table) {
        $table->string('priority')->nullable();
    });
    
    // Model
    protected $fillable = ['priority'];
    
  2. Custom Statuses Override the statuses config array to add/remove options:

    'statuses' => [
        'open' => 'Open',
        'pending' => 'Pending',
        'closed' => 'Closed',
        'escalated' => 'Escalated', // Custom status
    ],
    
  3. API Integration Use Laravel’s API resources to expose tickets:

    php artisan make:resource TicketResource
    

    Then return:

    return new TicketResource($ticket);
    
  4. Notifications Extend the package to send notifications (e.g., via Laravel Notifications) when tickets are created/updated:

    Ticket::created(function ($ticket) {
        $ticket->user->notify(new TicketCreated($ticket));
    });
    
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.
besmartand-pro/php-quality-config
sentix/ai-chatbot
terminal42/code-quality-tools
codifyo/ts-generator-bundle
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