sanjabteam / ticket
此包已被废弃,不再维护。未建议替代包。
sanjab管理面板的票据包。
v0.1.1
2020-12-27 12:48 UTC
Requires
- php: ^7.3
- illuminate/support: ^7|^8
- sanjabteam/sanjab: *
This package is auto-updated.
Last update: 2023-09-08 06:57:55 UTC
README
安装
首先,您应该为自定义编译准备Sanjab。
安装composer包。
composer require sanjabteam/ticket
安装npm包。
npm i sanjab-ticket --save-dev
在sanjab.js中提交sanjab-ticket插件,用于sanjab Vue实例。
require('sanjab'); Vue.use(require('sanjab-ticket').default); // Add this line if (document.querySelector('#sanjab_app')) { window.sanjabApp = new Vue({ el: '#sanjab_app', }); }
编译javascript
npm run watch
发布配置文件
php artisan vendor:publish --provider="SanjabTicket\SanjabTicketServiceProvider" --tag=config
将票据控制器添加到config/sanjab.php中的controllers
'controllers' => [ ... SanjabTicket\Controllers\TicketController::class, SanjabTicket\Controllers\TicketSettingController::class, ],
并在config/sanjab.php中的plugins/providers中添加提供者
'plugins' => [ /* |-------------------------------------------------------------------------- | Plugin's service providers that should be booted before sanjab service provider. |-------------------------------------------------------------------------- */ 'providers' => [ \SanjabTicket\SanjabTicketServiceProvider::class // Add this ], ],
迁移数据库
php artisan migrate
入门
提供一些票据类别/优先级。
确保在此次生成器之前已编写用户生成器,并确保您有超过1个用户。
php artisan make:seeder TicketSeeder
打开TicketSeeder并提供一些数据。
<?php 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(); } }
然后生成
php artisan db:seed --class=TicketsTableSeeder
配置
- 数据库
- 模型:用户模型类。
- 格式:显示用户名的格式。(例如:
"%first_name %last_name"
) - 字段:应在票据消息页面中显示的额外用户模型字段。(例如:
["email" => "E-Mail", "mobile" => "Mobile", "address" => "Address"]
)
- 文件
- 磁盘:保存票据文件的磁盘。
- 目录:磁盘中的目录。您可以使用{TICKET_ID}为每个票据创建目录。(例如:
tickets/{TICKET_ID}
)
- 通知
- new_ticket:提交新的票据消息时。
- admin:对所有有权访问票据部分的管理员的通知类
- client:在收到回复时提交票据的客户的通知类
- new_ticket:提交新的票据消息时。
通知
首先,确保您已创建通知表。
php artisan notification:table php artisan migrate
并确保您已在用户模型类中使用了Illuminate\Notifications\Notifiable
特质。
use Illuminate\Notifications\Notifiable; class User extends Authenticatable { use Notifiable, SanjabUser; ^^^^^^^^^^
然后您应该在sanjab导航栏顶部看到铃铛图标以用于通知。
为管理员创建一个通知类。
php artisan make:notification NewTicket
例如,我们只使用数据库。当然,您可以发送电子邮件和/或短信和/或任何其他方法。
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 ]; } }
然后将通知类提交到config/sanjab-ticket.php
'notifications' => [ // ... 'new_ticket' => [ //... 'admin' => \App\Notifications\NewTicket::class, ] ]
然后创建一个新票据。
php artisan tinker Psy Shell v0.9.12 (PHP 7.2.12 — cli) by Justin Hileman >>> \SanjabTicket\Models\Ticket::factory()->create()
客户端
完全取决于您。您只需要与这些模型类合作。
- SanjabTicket\Models\Ticket
- SanjabTicket\Models\TicketMessage
- SanjabTicket\Models\TicketCategory
- SanjabTicket\Models\TicketPriority
许可证
麻省理工学院许可证(MIT)。更多信息请参阅许可证文件。