You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

AuthServiceProvider.php 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. Setting\Category::class,
  34. Setting\Discount::class,
  35. Setting\Tax::class,
  36. Banking\Account::class,
  37. ];
  38. foreach ($models as $model) {
  39. Gate::policy($model, DefaultEnabledRecordPolicy::class);
  40. }
  41. }
  42. }