feat: add branch isolation for managers and zkteco biometric tracking
This commit is contained in:
@@ -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');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user