- 创建 RoleResource 及其所有页面类 - 实现角色列表、创建、编辑、查看功能 - 权限选择器按模块分组显示,支持批量选择 - 实现 super-admin 角色保护(不可编辑和删除) - 实现角色删除前检查(有关联用户时不可删除) - 创建 RolePolicy 控制角色管理权限 - 在 AppServiceProvider 中注册 RolePolicy - 角色列表显示权限数量和用户数量 - 完整的中文界面和提示信息
41 lines
1.1 KiB
PHP
41 lines
1.1 KiB
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);
|
|
Gate::policy(\Spatie\Permission\Models\Role::class, \App\Policies\RolePolicy::class);
|
|
}
|
|
}
|