PHP code example of sanjabteam / ticket

1. Go to this page and download the library: Download sanjabteam/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/ */

    

sanjabteam / ticket example snippets


'controllers' => [
    ...
    SanjabTicket\Controllers\TicketController::class,
    SanjabTicket\Controllers\TicketSettingController::class,
],

'plugins' => [
    /*
    |--------------------------------------------------------------------------
    | Plugin's service providers that should be booted before sanjab service provider.
    |--------------------------------------------------------------------------
    */
    'providers' => [
        \SanjabTicket\SanjabTicketServiceProvider::class // Add this
    ],
],



namespace Database\Seeders;

use App\Models\Ticket;
use App\Models\TicketCategory;
use Illuminate\Database\Seeder;
use SanjabTicket\Models\TicketPriority;

class TicketSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        TicketPriority::create(['name' => 'Low', 'color' => '#000000']);
        TicketPriority::create(['name' => 'Normal', 'color' => '#00ff00']);
        TicketPriority::create(['name' => 'High', 'color' => '#ff9800']);
        TicketPriority::create(['name' => 'Emergency', 'color' => '#ff0000']);

        TicketCategory::create(['name' => 'Support', 'color' => '#00ff00']);
        TicketCategory::create(['name' => 'Technical', 'color' => '#0000ff']);
        TicketCategory::create(['name' => 'Suggestion', 'color' => '#000000']);
        TicketCategory::create(['name' => 'Criticism', 'color' => '#ff9800']);
        TicketCategory::create(['name' => 'Sue', 'color' => '#ff0000']);

        Ticket::factory(50)->create();
    }
}

use Illuminate\Notifications\Notifiable;

class User extends Authenticatable
{
    use Notifiable, SanjabUser;
        ^^^^^^^^^^

use SanjabTicket\Models\Ticket;

class NewTicket extends Notification
{
    use Queueable;

    /**
     * Ticket
     *
     * @var Ticket
     */
    protected $ticket;

    /**
     * Create a new notification instance.
     *
     * @return void
     */
    public function __construct(Ticket $ticket)
    {
        $this->ticket = $ticket;
    }

    /**
     * Get the notification's delivery channels.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function via($notifiable)
    {
        return ['database'];
    }

    /**
     * Get the array representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function toArray($notifiable)
    {
        return [
            'text' => 'New ticket by '.$this->ticket->user->name,
            'url' => route('sanjab.modules.tickets.show', ['id' => $this->ticket->id]), // Url to chat page
            'toast' => true, // Show a toast alert on top
            'sound' => true, // Play notification sound
        ];
    }
}

'notifications' => [
        // ...
        'new_ticket' => [
            //...
            'admin' => \App\Notifications\NewTicket::class,
        ]
]
bash
php artisan vendor:publish --provider="SanjabTicket\SanjabTicketServiceProvider" --tag=config
bash
php artisan migrate
bash
php artisan make:seeder TicketSeeder
bash
php artisan db:seed --class=TicketsTableSeeder
bash
php artisan notification:table
php artisan migrate
bash
php artisan make:notification NewTicket
bash
php artisan tinker
Psy Shell v0.9.12 (PHP 7.2.12 — cli) by Justin Hileman
>>> \SanjabTicket\Models\Ticket::factory()->create()