ldc-legaulois/app/Providers/AuthServiceProvider.php
2026-09-25 16:25:31 +02:00

35 lines
968 B
PHP

<?php
namespace App\Providers;
use App\Auth\CrmUserProvider;
use App\Enums\Users\RoleEnum;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Gate;
class AuthServiceProvider extends ServiceProvider
{
/**
* The model to policy mappings for the application.
*
* @var array<class-string, class-string>
*/
protected $policies = [];
/**
* Register any authentication / authorization services.
*/
public function boot(): void
{
Gate::define('isConceptor', function (Model $authModel) {
return isset($authModel->role) && $authModel->role === RoleEnum::conceptor;
});
// * CRM
// @phpstan-ignore-next-line
$this->app->auth->provider('crm', function ($app, array $config) {
return new CrmUserProvider($app['hash'], $config['model']);
});
}
}