feat: add branch isolation for managers and zkteco biometric tracking

This commit is contained in:
2026-07-02 13:06:09 +08:00
parent 1974ea1982
commit d40c5662d3
8550 changed files with 707373 additions and 24328 deletions

View File

@@ -56,8 +56,15 @@ class LeaveApplicationController extends Controller
->where(function ($q) {
if (Auth::user()->can('manage-any-leave-applications')) {
$q->whereIn('created_by', getCompanyAndUsersId());
} elseif (Auth::user()->can('manage-own-leave-applications')) {
$q->where('created_by', Auth::id())->orWhere('employee_id', Auth::id())->orWhere('approved_by', Auth::id());
} elseif (Auth::user()->can('manage-leave-applications')) {
$branchId = Auth::user()->employee->branch_id ?? null;
if ($branchId) {
$q->whereHas('employee.employee', function ($eq) use ($branchId) {
$eq->where('branch_id', $branchId);
});
} else {
$q->where('created_by', Auth::id())->orWhere('employee_id', Auth::id())->orWhere('approved_by', Auth::id());
}
} else {
$q->whereRaw('1 = 0');
}