7. In the AuthServiceProvider.php file, add the following ( Super Admin Role ):
use Illuminate\Support\Facades\Gate;
public function boot()
{
Gate::before(function ($user, $ability) {
return $user?->role?->id === 1;
});
}
Line error:
return $user?->role?->id === 1;
With this option, all users whose role?->id !== 1will be denied access
Line error:
return $user?->role?->id === 1;
With this option, all users whoserole?->id !== 1
will be denied accessCorrect option:
return $user?->role?->id === 1 ? true : null;