- 更新 DocumentPolicy 添加权限检查 - viewAny/view/create/update/delete/download 都检查相应权限 - 保留现有的分组访问控制逻辑 - 保留安全日志记录功能 - 更新 TerminalPolicy 添加权限检查 - 所有方法都基于 terminal.* 权限 - 新增 sync 方法用于配置同步权限检查 - 更新 SopTemplatePolicy 添加权限检查 - 所有方法都基于 sop-template.* 权限 - 保留现有的状态检查逻辑(已发布不可编辑/删除) - 创建 SystemSettingPolicy - 实现 viewAny/view/update 权限检查 - 创建 ActivityLogPolicy - 实现 viewAny/view/export 权限检查 - 创建 GroupPolicy - 实现完整的 CRUD 权限检查 - 删除前检查关联文档和用户 - 在 AppServiceProvider 中注册所有策略
45 lines
1.4 KiB
PHP
45 lines
1.4 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);
|
|
Gate::policy(\App\Models\User::class, \App\Policies\UserPolicy::class);
|
|
Gate::policy(\App\Models\SystemSetting::class, \App\Policies\SystemSettingPolicy::class);
|
|
Gate::policy(\Spatie\Activitylog\Models\Activity::class, \App\Policies\ActivityLogPolicy::class);
|
|
Gate::policy(\App\Models\Group::class, \App\Policies\GroupPolicy::class);
|
|
}
|
|
}
|