npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

sanjab-ticket

v0.0.6

Published

Ticketing for sanjab (https://github.com/sanjabteam/sanjab)

Downloads

1

Readme

Support ticketing for Sanjab

Installation

First, you should prepare Sanjab for custom compile.

Custom Compile Sanjab

Install the composer package.

composer require sanjabteam/ticket

Install the npm package.

npm i sanjab-ticket --save-dev

Submit sanjab-ticket plugin for sanjab Vue instance in sanjab.js:

require('sanjab');

Vue.use(require('sanjab-ticket').default); // Add this line

if (document.querySelector('#sanjab_app')) {
    window.sanjabApp = new Vue({
        el: '#sanjab_app',
    });
}

Compile javascript:

npm run watch

Publish config file:

php artisan vendor:publish --provider="SanjabTicket\SanjabTicketServiceProvider" --tag=config

Add ticket controllers to controllers in config/sanjab.php:

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

and add provider to plugins/providers:

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

Migrate database:

php artisan migrate

Go to the admin panel and Tickets and Ticket Settings should be in the sidebar. Screenshot

Getting started

Provide some ticket category/priority.

Make sure you wrote seeder for users before this seeder and make sure you have more than 1 user.

php artisan make:seeder TicketsTableSeeder

Open TicketsTableSeeder and provide some data.

<?php

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

class TicketsTableSeeder 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']);

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

And seed:

php artisan db:seed --class=TicketsTableSeeder

Screenshot Screenshot

Configuration

  • database
    • model: The user model class.
    • format: Format of showing user name. (Example: "%first_name %last_name")
    • fields: Extra user model fileds that should be shown in ticket messages page. (Example: ["email" => "E-Mail", "mobile" => "Mobile", "address" => "Address"])
  • files
    • disk: Disk to save ticket files.
    • directory: Directory in the disk. You can use {TICKET_ID} to make directory per ticket. (Example: tickets/{TICKET_ID})
  • notifications
    • new_ticket: When new ticket message submitted.
      • admin: Notification class for all admins that has access to the tickets section
      • client: Notification class for the client that submitted ticket when got an answer.

Notification

First, make sure you created the Notifications table.

php artisan notification:table
php artisan migrate

and also make sure you used Illuminate\Notifications\Notifiable trait in your user model class.

use Illuminate\Notifications\Notifiable;

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

Then you should see a bell icon in the sanjab navbar at the top for notifications.

Create a notification class for admins.

php artisan make:notification NewTicket

For example, we only gonna use the database. Of course, you can send an email and/or SMS and/or any other method.

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
        ];
    }
}

And then submit notification class in config/sanjab-ticket.php:

'notifications' => [
        // ...
        'new_ticket' => [
            //...
            'admin' => \App\Notifications\NewTicket::class,
        ]
]

And now make a new ticket.

php artisan tinker
Psy Shell v0.9.12 (PHP 7.2.12 — cli) by Justin Hileman
>>> factory(\SanjabTicket\Models\Ticket::class)->create()

Screenshot

Client-side

It's all up to you. You only need to work with these model classes.

License

The MIT License (MIT). Please see License File for more information.