您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

AuthServiceProvider.php 1.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace App\Providers;
  3. use App\Models\Banking;
  4. use App\Models\Setting;
  5. use App\Policies\DefaultEnabledRecordPolicy;
  6. use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
  7. use Illuminate\Support\Facades\Gate;
  8. class AuthServiceProvider extends ServiceProvider
  9. {
  10. /**
  11. * The model to policy mappings for the application.
  12. *
  13. * @var array<class-string, class-string>
  14. */
  15. protected $policies = [
  16. //
  17. ];
  18. /**
  19. * Register any authentication / authorization services.
  20. */
  21. public function boot(): void
  22. {
  23. $this->registerPolicies();
  24. $this->registerEnabledRecordPolicy();
  25. }
  26. /**
  27. * Register the policy for the enabled record.
  28. */
  29. protected function registerEnabledRecordPolicy(): void
  30. {
  31. $models = [
  32. Setting\Currency::class,
  33. Banking\BankAccount::class,
  34. ];
  35. foreach ($models as $model) {
  36. Gate::policy($model, DefaultEnabledRecordPolicy::class);
  37. }
  38. }
  39. }