In Laravel 11, i created a new Service Provider class for authorization, and defined gates and blade directives in the boot method like these:
Gate::define('admin', function (User $user) {
return $user?->type === 0;
});
Gate::define('author', function (User $user) {
return $user?->type === 1;
});
Blade::if('admin', function () {
return request()->user()?->can('admin');
});
Blade::if('author', function () {
return request()->user()?->can('author');
});
My question: Is defining these gates and blade directives in the boot method is right or not a good practice to define much logic in the boot method ? and if yes, where can i defining them ?
Thanks in advance