04
OctA Laravel Ticket Package is a Backend API to handle your ticket system, in an easy way.
You can install the package via composer:
composer require coderflex/laravel-ticket
You can publish the config file with:
php artisan vendor:publish --tag="ticket-config"
You can publish and run the migrations with:
php artisan vendor:publish --tag="ticket-migrations"
Before Running the migration, you may publish the config file.
php artisan migrate
Add HasTickets
trait into your User model, along with CanUseTickets
interface
use Coderflex\LaravelTicket\Concerns\HasTickets;
use Coderflex\LaravelTicket\Contracts\CanUseTickets;
...
class User extends Model implements CanUseTickets
{
...
use HasTickets;
...
}
The Basic Usage of this package is to create a ticket, then associate the labels and the categories.
You can associate as many as categories/labels
into a single ticket.
Here is an example.
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());
$categories = Category::first();
$labels = Label::first();
$ticket->attachCategories($categories);
$ticket->attachLabels($labels);
// 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 separated from the ticket and want 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 separated from the ticket and want to
// associate it to a ticket, you may do the following.
$category = Category::create(...);
$category->tickets()->attach($ticket);
// or maybe
$category->tickets()->detach($ticket);
}
This package has many Options and API methods with code examples. If you want to dig more then please visit Github.
If you are an enterprise and want to use develop a CRM, e-commerce, or SAAS web application in Laravel, you must discover an impeccable team with proficiency in the Laravel framework. So Codebrisk is here to help you with your tailored requirements regarding Laravel Development. Our CRM development with Laravel holds a wide range of features for entities to manage their interactions with customers.
So if you have a great idea, then please feel free to contact us or you can launch a project with us.
Published at : 04-10-2022
I am a highly results-driven professional with 12+ years of collective experience in the grounds of web application development especially in laravel, native android application development in java, and desktop application development in the dot net framework. Now managing a team of expert developers at Codebrisk.
Launch project