37 lines
905 B
PHP
37 lines
905 B
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use App\Models\PurchaseHistory;
|
|
use App\Models\Tenant;
|
|
use App\Models\User;
|
|
use App\Policies\PurchaseHistoryPolicy;
|
|
use App\Policies\TenantPolicy;
|
|
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 = [
|
|
Tenant::class => TenantPolicy::class,
|
|
PurchaseHistory::class => PurchaseHistoryPolicy::class,
|
|
];
|
|
|
|
/**
|
|
* Register any authentication / authorization services.
|
|
*/
|
|
public function boot(): void
|
|
{
|
|
$this->registerPolicies();
|
|
|
|
Gate::before(function (User $user): ?bool {
|
|
return $user->role === 'super_admin' ? true : null;
|
|
});
|
|
}
|
|
}
|