Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

AuthServiceProvider.php 1.1KB

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