feat: implement super admin role with spatie rbac and categorize sidebar by management
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
@@ -21,5 +22,10 @@ class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
\Carbon\Carbon::setLocale('id');
|
||||
date_default_timezone_set(config('app.timezone', 'Asia/Jakarta'));
|
||||
|
||||
// Super Admin bypass: secara otomatis memiliki izin untuk semua ability
|
||||
Gate::before(function ($user, $ability) {
|
||||
return ($user->role === 'super_admin' || $user->hasRole('super_admin')) ? true : null;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user