41 lines
932 B
PHP
41 lines
932 B
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
|
use Illuminate\Support\Facades\Gate;
|
|
|
|
class AuthServiceProvider extends ServiceProvider
|
|
{
|
|
/**
|
|
* The policy mappings for the application.
|
|
*
|
|
* @var array<class-string, class-string>
|
|
*/
|
|
protected $policies = [
|
|
// 'App\Models\Model' => 'App\Policies\ModelPolicy',
|
|
];
|
|
|
|
/**
|
|
* Register any authentication / authorization services.
|
|
*/
|
|
public function boot()
|
|
{
|
|
$this->registerPolicies();
|
|
|
|
// SUPER ADMIN bypass
|
|
Gate::before(function ($user, $ability) {
|
|
if ($user->hasRole('super-admin')) {
|
|
return true;
|
|
}
|
|
});
|
|
|
|
// ADMIN bypass
|
|
Gate::before(function ($user, $ability) {
|
|
if ($user->hasRole('admin')) {
|
|
return true;
|
|
}
|
|
});
|
|
}
|
|
}
|