AuthServiceProvider.php 627 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. namespace App\Providers;
  3. use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
  4. use Illuminate\Support\Facades\Gate;
  5. class AuthServiceProvider extends ServiceProvider
  6. {
  7. /**
  8. * The model to policy mappings for the application.
  9. *
  10. * @var array<class-string, class-string>
  11. */
  12. protected $policies = [
  13. //
  14. ];
  15. /**
  16. * Register any authentication / authorization services.
  17. */
  18. public function boot(): void
  19. {
  20. Gate::before(static function ($user) {
  21. return $user->hasRole('Super Admin') ? true : null;
  22. });
  23. }
  24. }