ldc-legaulois/app/Providers/AuthServiceProvider.php

36 lines
968 B
PHP
Raw Permalink Normal View History

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