1. Go to this page and download the library: Download coderflex/laravel-ticket library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
coderflex / laravel-ticket example snippets
...
use Coderflex\LaravelTicket\Concerns\HasTickets;
use Coderflex\LaravelTicket\Contracts\CanUseTickets;
...
class User extends Model implements CanUseTickets
{
...
use HasTickets;
...
}
use Coderflex\LaravelTicket\Models\Ticket;
use Coderflex\LaravelTicket\Models\Category;
use Coderflex\LaravelTicket\Models\Label;
...
public function store(Request $request)
{
/** @var User */
$user = Auth::user();
$ticket = $user->tickets()
->create($request->validated());
$category = Category::first();
$label = Label::first();
$ticket->attachCategories($category);
$ticket->attachLabels($label);
// or you can create the categories & the tickets directly by:
// $ticket->categories()->create(...);
// $ticket->labels()->create(...);
return redirect(route('tickets.show', $ticket->uuid))
->with('success', __('Your Ticket Was created successfully.'));
}
public function createLabel()
{
// If you create a label seperated from the ticket and wants to
// associate it to a ticket, you may do the following.
$label = Label::create(...);
$label->tickets()->attach($ticket);
// or maybe
$label->tickets()->detach($ticket);
}
public function createCategory()
{
// If you create a category/categories seperated from the ticket and wants to
// associate it to a ticket, you may do the following.
$category = Category::create(...);
$category->tickets()->attach($ticket);
// or maybe
$category->tickets()->detach($ticket);
}
...
$ticket->archive()
->close()
->markAsResolved();
namespace App\Models\Ticket;
use Spatie\MediaLibrary\HasMedia;
use Spatie\MediaLibrary\InteractsWithMedia;
class Ticket extends \Coderflex\LaravelTicket\Models\Ticket implements HasMedia
{
use InteractsWithMedia;
}