44 lines
1.5 KiB
PHP
44 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use Illuminate\Support\Facades\Gate;
|
|
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
|
use App\Models\Patient;
|
|
use App\Models\Appointment;
|
|
use App\Policies\PatientPolicy;
|
|
use App\Policies\AppointmentPolicy;
|
|
use App\Policies\InvoicePolicy;
|
|
use App\Policies\LedgerPolicy;
|
|
use App\Policies\WagePolicy;
|
|
|
|
class AuthServiceProvider extends ServiceProvider
|
|
{
|
|
protected $policies = [
|
|
Patient::class => PatientPolicy::class,
|
|
Appointment::class => AppointmentPolicy::class,
|
|
];
|
|
|
|
public function boot(): void
|
|
{
|
|
// Gates for invoices
|
|
Gate::define('view-invoices', [InvoicePolicy::class, 'viewAny']);
|
|
Gate::define('create-invoices', [InvoicePolicy::class, 'create']);
|
|
|
|
// Gates for ledger
|
|
Gate::define('view-ledger', [LedgerPolicy::class, 'viewAny']);
|
|
Gate::define('create-ledger', [LedgerPolicy::class, 'create']);
|
|
Gate::define('view-reports', [LedgerPolicy::class, 'viewReports']);
|
|
|
|
// Gates for wages
|
|
Gate::define('view-wages', [WagePolicy::class, 'viewAny']);
|
|
Gate::define('approve-wages', [WagePolicy::class, 'approve']);
|
|
|
|
// Role-based gates
|
|
Gate::define('is-admin', fn($user) => $user->role === 'admin');
|
|
Gate::define('is-manager', fn($user) => in_array($user->role, ['admin', 'manager']));
|
|
Gate::define('is-therapist', fn($user) => $user->role === 'therapist');
|
|
Gate::define('is-receptionist', fn($user) => $user->role === 'receptionist');
|
|
}
|
|
}
|