sdkcodes / lara-ticket
用于处理“支持票”的Laravel 5包
0.0.3
2019-01-25 18:23 UTC
Requires
- illuminate/support: ^5.1
- laravel/framework: ^5.1
This package is auto-updated.
Last update: 2024-09-21 20:51:15 UTC
README
这是一个Laravel 5包,用于在项目中处理票务支持系统
关于
这是一个Laravel 5包,用于在项目中处理票务支持系统。LaraTicket与现有用户数据库和身份验证系统很好地集成。您还可以自由配置一些选项,使其更符合您的项目。LaraTicket可以直接使用,无需额外努力或配置。特性
- 两个主要用户角色(管理员和用户)
- 用户可以创建票务、添加评论、打开和关闭票务
- 功能丰富的富文本编辑器,支持图片和视频嵌入
- 使用bootstrap 4
- 易于使用的管理面板
- 自定义视图,无需编写自己的视图
- 自定义预定义路由
安装
- 要安装LaraTicket,在现有项目根目录中运行
composer require sdkcodes/lara-ticket 0.0.3
- 如果您使用的是Laravel < 5.4,请复制并添加此行到您的
config/app.php
文件中的providers
数组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;
...
- Laravel >= 5.5会自动发现包,因此您无需手动添加。
- 使用命令
php artisan vendor:publish
发布视图、配置和迁移 - 将此特质添加到您的用户模型中
use UserTicket;
不要忘记导入特质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'
];
您可以根据需要更改配置值
- 运行
php artisan migrate
执行必要的迁移 - LaraTicket会更改您的用户表,以添加一个新列
laraticket_admin
。 - 将此列的值更改为true(或1),以将任何用户设置为票务管理员
- 访问您的项目URL
/tickets
开始使用。 - 管理员可以(应该)根据需要添加类别和优先级
事件
版本0.0.2及以上
此包发出4种不同的操作,您可以在应用程序中监听这些操作以执行相关和必要的操作。这些事件包括
* 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)
使用您自己的监听器,您可以决定执行不同的操作,例如向相关方发送通知等。
例如,要监听TicketSubmitted
事件,将以下内容添加到您的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();
}
}
您的事件监听器代码
<?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");
}
}
路由
- Route::get('admin/tickets', "TicketController@index");
- Route::get('tickets/create', "TicketController@create");
- Route::get('tickets/{status?}', "TicketController@index");
- Route::get('tickets/show/{ticket}', "TicketController@show");
- Route::get('tickets/{ticket}/update', "TicketController@changestatus");
- Route::post('tickets/store', "TicketController@store");
- Route::put('tickets/{ticket}', "TicketController@update");
- Route::delete('tickets/{ticket}', "TicketController@delete");
- Route::post('tickets/comments/store/{ticket}', "TicketController@reply");
- Route::get('admin/tickets/options/settings', "TicketOptionController@options");
- Route::post('admin/tickets/options/settings', "TicketOptionController@store");
- Route::put('admin/tickets/options/settings', "TicketOptionController@update");
许可证
LaraTicket遵循MIT许可证。按您喜欢的任何方式使用和享受!