- 在 AppServiceProvider 中注册 DocumentPolicy - 在 AppServiceProvider 中注册 TerminalPolicy - 修复文档管理、终端管理、SOP模板在导航中不显示的问题 - 确保所有资源的权限检查正常工作
40 lines
1000 B
PHP
40 lines
1000 B
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use App\Models\Document;
|
|
use App\Models\SopTemplate;
|
|
use App\Observers\DocumentObserver;
|
|
use App\Policies\SopTemplatePolicy;
|
|
use Carbon\Carbon;
|
|
use Illuminate\Support\Facades\Gate;
|
|
use Illuminate\Support\ServiceProvider;
|
|
|
|
class AppServiceProvider extends ServiceProvider
|
|
{
|
|
/**
|
|
* Register any application services.
|
|
*/
|
|
public function register(): void
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Bootstrap any application services.
|
|
*/
|
|
public function boot(): void
|
|
{
|
|
// 配置 Carbon 使用中文
|
|
Carbon::setLocale('zh_CN');
|
|
|
|
// 注册文档观察者,用于自动管理 Meilisearch 索引
|
|
Document::observe(DocumentObserver::class);
|
|
|
|
// 注册策略
|
|
Gate::policy(\App\Models\Document::class, \App\Policies\DocumentPolicy::class);
|
|
Gate::policy(\App\Models\Terminal::class, \App\Policies\TerminalPolicy::class);
|
|
Gate::policy(SopTemplate::class, SopTemplatePolicy::class);
|
|
}
|
|
}
|