2026-09-16 11:43:27 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Providers;
|
|
|
|
|
|
2026-10-21 00:48:38 +02:00
|
|
|
use App\Models\User;
|
|
|
|
|
use Illuminate\Support\Facades\Gate;
|
2026-09-16 11:43:27 +02:00
|
|
|
use Illuminate\Support\ServiceProvider;
|
|
|
|
|
|
|
|
|
|
class AppServiceProvider extends ServiceProvider
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Register any application services.
|
|
|
|
|
*/
|
|
|
|
|
public function register(): void
|
|
|
|
|
{
|
2026-10-21 00:48:38 +02:00
|
|
|
// TP8 bonus : l'administration est une capacité globale, donc un Gate est adapté.
|
|
|
|
|
Gate::define('viewAdmin', fn (User $user): bool => $user->is_admin);
|
2026-09-16 11:43:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Bootstrap any application services.
|
|
|
|
|
*/
|
|
|
|
|
public function boot(): void
|
|
|
|
|
{
|
|
|
|
|
//
|
|
|
|
|
}
|
|
|
|
|
}
|