ldc-gen-game-web/app/Providers/AuthServiceProvider.php
Jérémy Munsch 232bc2f459
Tons of Bo fixes related to product and ranges,
add picture alt and titles + seeders + correct config
picture sizes
2023-11-29 15:33:23 +01:00

42 lines
1.1 KiB
PHP

<?php
namespace App\Providers;
use App\Auth\CrmUserProvider;
use App\Enums\Users\RoleEnum;
use App\Models\Product;
use App\Models\User;
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.
*
* @return void
*/
public function boot(): void
{
Gate::define('isConceptor', function (User $user) {
return $user->role === RoleEnum::conceptor;
});
Gate::define(
'fo.showProducts',
// phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass
fn (?User $user) => view()->exists('theme::pages.products') and (bool)Product::query()->count()
);
$this->app->auth->provider('crm', function ($app, array $config) {
return new CrmUserProvider($app['hash'], $config['model']);
});
}
}