Downloads
Stars
Version
composer require sdkcodes/lara-ticket 0.0.3
providers
array in your config/app.php
file
Sdkcodes\LaraTicket\LaraTicketServiceProvider::class,
<?php
namespace App;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Sdkcodes\LaraTicket\Traits\UserTicket;
class User extends Authenticatable
{
use UserTicket;
...
php artisan vendor:publish
use UserTicket;
Don't forget to import the trait use Sdkcodes\LaraTicket\Traits\UserTicket;
return[
'layout' => 'layouts.front',
/*
|--------------------------
| If you probably need to use a different template layout for the admin part of the ticket
| you can make change this value to match
|--------------------------
*/
'admin_layout' => 'layouts.master',
/**
* In case your default users tablename is not users
* You can change this value to reflect your table name
* This will have an effect in migrations
*
* *
* */
'user_table_name' => 'users',
/**
* Change this value if your user model is not located in the laravel's default App directory
*
* */
'user_model_namespace' => 'App\User',
/**@internal Where should users be taken to when they click on navbar brand
**/
'return_url' => 'dashboard'
];
You can change the configuration values as needed
php artisan migrate
to do the necessary migrationslaraticket_admin
./tickets
to begin usage. version 0.0.2 upwards
This package emits 4 different actions that you can listen for in your app to perform related and necessary actions. These events are:
* Sdkcodes\LaraTicket\TicketSubmitted ($ticket object becomes available to your listener)
* Sdkcodes\LaraTicket\TicketReplied ($comment object becomes available to your listener)
* Sdkcodes\LaraTicket\TicketClosed ($ticket object becomes available to your listener)
* Sdkcodes\LaraTicket\TicketDeleted ($ticket object becomes available to your listener)
With your own listeners, you can decide to do different things like send notifications to concerned parties etc.
E.g
To listen for a TicketSubmitted
event, add this to your EventServiceProvider.php
<?php
namespace App\Providers;
use Illuminate\Support\Facades\Event;
use Illuminate\Auth\Events\Registered;
use Sdkcodes\LaraTicket\Events\TicketSubmitted;
use App\Listeners\SendTicketSubmissionNotification;
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
class EventServiceProvider extends ServiceProvider
{
/**
* The event listener mappings for the application.
*
* @var array
*/
protected $listen = [
Registered::class => [
SendEmailVerificationNotification::class,
],
TicketSubmitted::class => [
SendTicketSubmissionNotification::class
],
'Sdkcodes\LaraTicket\Events\TicketDeleted' => [
'App\Listeners\SendTicketDeletionNotification'
],
'Sdkcodes\LaraTicket\Events\TicketReplied' => [
'App\Listeners\SendTicketRepliedNotifcation'
],
'Sdkcodes\LaraTicket\Events\TicketClosed' => [
'App\Listeners\SendTicketClosedNotifcation'
]
];
/**
* Register any events for your application.
*
* @return void
*/
public function boot()
{
parent::boot();
}
}
Your event listener code
<?php
namespace App\Listeners;
use Illuminate\Support\Facades\Log;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Sdkcodes\LaraTicket\Events\TicketSubmitted;
class SendTicketSubmissionNotification
{
/**
* Create the event listener.
*
* @return void
*/
public function __construct()
{
}
/**
* Handle the event.
*
* @param object $event
* @return void
*/
public function handle($event)
{
$ticket = $event->ticket;
Log::info("Ticket has been submitted, we can send mail now or anything else");
}
}
LaraTicket is MIT Licensed. Use and enjoy as you like!