2023-03-14 14:57:03 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Providers;
|
|
|
|
|
|
2025-05-20 16:20:23 +02:00
|
|
|
use App\Enums\UserRolesEnum;
|
2023-09-13 16:04:12 +02:00
|
|
|
use App\Models\User;
|
2023-03-14 14:57:03 +01:00
|
|
|
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
2023-09-13 16:04:12 +02:00
|
|
|
use Illuminate\Support\Facades\Gate;
|
2023-03-14 14:57:03 +01:00
|
|
|
|
|
|
|
|
class AuthServiceProvider extends ServiceProvider
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Register any authentication / authorization services.
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
2025-05-20 10:16:12 +02:00
|
|
|
public function boot(): void
|
2023-03-14 14:57:03 +01:00
|
|
|
{
|
|
|
|
|
$this->registerPolicies();
|
2023-09-13 16:04:12 +02:00
|
|
|
|
2025-05-20 16:20:23 +02:00
|
|
|
Gate::define('isAdmin', function (User $user) {
|
|
|
|
|
return $user->role->equals(UserRolesEnum::admin);
|
|
|
|
|
});
|
2023-03-14 14:57:03 +01:00
|
|
|
}
|
|
|
|
|
}
|