2026-05-07 23:31:33 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Providers;
|
|
|
|
|
|
|
|
|
|
use Illuminate\Support\ServiceProvider;
|
2026-06-17 16:39:28 +02:00
|
|
|
use Illuminate\Support\Facades\Gate;
|
2026-05-07 23:31:33 +02:00
|
|
|
|
|
|
|
|
class AppServiceProvider extends ServiceProvider
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Register any application services.
|
|
|
|
|
*/
|
|
|
|
|
public function register(): void
|
|
|
|
|
{
|
|
|
|
|
//
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Bootstrap any application services.
|
|
|
|
|
*/
|
|
|
|
|
public function boot(): void
|
|
|
|
|
{
|
2026-06-17 16:39:28 +02:00
|
|
|
// Super-admin bypass: anyone with the "manage all" permission
|
|
|
|
|
// (the Admin role has it) passes every authorization check.
|
|
|
|
|
// Return true to allow, or null to let normal checks run — never false.
|
|
|
|
|
Gate::before(function ($user, $ability) {
|
|
|
|
|
try {
|
|
|
|
|
return $user->hasPermissionTo('manage all') ? true : null;
|
|
|
|
|
} catch (\Throwable $e) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
});
|
2026-05-07 23:31:33 +02:00
|
|
|
}
|
|
|
|
|
}
|