AppServiceProvider.php 995B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace App\Providers;
  3. use Illuminate\Support\Facades\App;
  4. use Illuminate\Support\Facades\Gate;
  5. use Illuminate\Support\Facades\URL;
  6. use Illuminate\Support\ServiceProvider;
  7. class AppServiceProvider extends ServiceProvider
  8. {
  9. /**
  10. * Register any application services.
  11. */
  12. public function register(): void
  13. {
  14. //
  15. }
  16. /**
  17. * Bootstrap any application services.
  18. */
  19. public function boot(): void
  20. {
  21. if (App::environment('production')) {
  22. URL::forceScheme('https');
  23. }
  24. if (app()->environment('local', 'testing', 'Staging')) {
  25. URL::forceScheme('http');
  26. }
  27. Gate::before(function ($user, $ability) {
  28. if ($user->email == env("SUPER_ADMIN_ACCOUNT", "admin@ogilvy.com")) {
  29. return true; // Super admin always passes
  30. }
  31. // Continue to policy logic for other users
  32. return null; // Null lets the policy decide
  33. });
  34. }
  35. }