Deploy Ladill Care / deploy (push) Failing after 13s
Healthcare management app: patients, appointments, consultations, lab, pharmacy inventory, billing, and reports at care.ladill.com. Co-authored-by: Cursor <cursoragent@cursor.com>
71 lines
2.2 KiB
PHP
71 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace App\Services\Care;
|
|
|
|
use App\Models\Member;
|
|
|
|
class CarePermissions
|
|
{
|
|
/** @var array<string, list<string>> */
|
|
protected array $roleAbilities = [
|
|
'super_admin' => ['*'],
|
|
'hospital_admin' => ['*'],
|
|
'receptionist' => [
|
|
'dashboard.view', 'patients.view', 'patients.manage',
|
|
'appointments.view', 'appointments.manage', 'queue.manage',
|
|
],
|
|
'doctor' => [
|
|
'dashboard.view', 'patients.view', 'appointments.view',
|
|
'consultations.view', 'consultations.manage',
|
|
'investigations.request', 'prescriptions.manage', 'lab.results.view',
|
|
],
|
|
'nurse' => [
|
|
'dashboard.view', 'patients.view', 'appointments.view',
|
|
'consultations.view', 'vitals.manage', 'queue.manage',
|
|
],
|
|
'lab_technician' => [
|
|
'dashboard.view', 'patients.view', 'lab.view', 'lab.manage',
|
|
],
|
|
'pharmacist' => [
|
|
'dashboard.view', 'patients.view', 'prescriptions.view', 'prescriptions.dispense',
|
|
'pharmacy.view', 'pharmacy.manage',
|
|
],
|
|
'cashier' => [
|
|
'dashboard.view', 'patients.view', 'bills.view', 'bills.manage', 'payments.manage',
|
|
],
|
|
'accountant' => [
|
|
'dashboard.view', 'bills.view', 'reports.finance.view', 'reports.finance.export',
|
|
'audit.view', 'audit.export',
|
|
],
|
|
];
|
|
|
|
/** @var list<string> */
|
|
protected array $adminAbilities = [
|
|
'admin.branches.view', 'admin.branches.manage',
|
|
'admin.departments.view', 'admin.departments.manage',
|
|
'admin.members.view', 'admin.members.manage',
|
|
'settings.view', 'settings.manage',
|
|
'audit.view', 'audit.export',
|
|
];
|
|
|
|
public function can(?Member $member, string $ability): bool
|
|
{
|
|
if ($member === null) {
|
|
return false;
|
|
}
|
|
|
|
$abilities = $this->roleAbilities[$member->role] ?? [];
|
|
|
|
if (in_array('*', $abilities, true)) {
|
|
return true;
|
|
}
|
|
|
|
return in_array($ability, $abilities, true);
|
|
}
|
|
|
|
public function isAdmin(?Member $member): bool
|
|
{
|
|
return $member !== null && in_array($member->role, ['super_admin', 'hospital_admin'], true);
|
|
}
|
|
}
|