38 lines
930 B
PHP
Executable File
38 lines
930 B
PHP
Executable File
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
|
use Illuminate\Support\Facades\Gate;
|
|
use App\Models\Subject;
|
|
use App\Models\UserInterest;
|
|
use App\Policies\SubjectPolicy;
|
|
use App\Policies\UserInterestPolicy;
|
|
|
|
/**
|
|
* Application authentication and authorization service provider.
|
|
*/
|
|
class AuthServiceProvider extends ServiceProvider
|
|
{
|
|
/**
|
|
* The model to policy mappings for the application.
|
|
*/
|
|
protected $policies = [
|
|
Subject::class => SubjectPolicy::class,
|
|
UserInterest::class => UserInterestPolicy::class,
|
|
];
|
|
|
|
/**
|
|
* Register any authentication / authorization services.
|
|
*/
|
|
public function boot(): void
|
|
{
|
|
$this->registerPolicies();
|
|
|
|
Gate::before(function ($user, $ability) {
|
|
if ($user->hasRole('superadmin')) {
|
|
return true;
|
|
}
|
|
});
|
|
}
|
|
} |