Implement HR Branch isolation and Shift isolation

This commit is contained in:
2026-07-14 11:41:04 +08:00
parent 778bf0f52b
commit 8f078c1f33
427 changed files with 14658 additions and 14552 deletions

View File

@@ -47,7 +47,7 @@ class AttendanceRecordController extends Controller
if (Auth::user()->can('manage-any-attendance-records')) {
$q->whereIn('created_by', getCompanyAndUsersId());
} elseif (Auth::user()->can('manage-attendance-records')) {
$branchId = Auth::user()->employee->branch_id ?? null;
$branchId = Auth::user()->branch_id ?? Auth::user()->employee->branch_id ?? null;
if ($branchId) {
$q->where(function ($subQ) use ($branchId) {
$subQ->where('attendance_records.branch_id', $branchId)
@@ -200,7 +200,7 @@ class AttendanceRecordController extends Controller
$employeeQuery = Employee::whereIn('created_by', getCompanyAndUsersId());
if (Auth::user()->can('manage-attendance-records') && !Auth::user()->can('manage-any-attendance-records')) {
$branchId = Auth::user()->employee->branch_id ?? null;
$branchId = Auth::user()->branch_id ?? Auth::user()->employee->branch_id ?? null;
if ($branchId) {
$employeeQuery->where('branch_id', $branchId);
} else {
@@ -1141,7 +1141,7 @@ class AttendanceRecordController extends Controller
if (Auth::user()->can('manage-any-attendance-records')) {
$query->whereIn('created_by', getCompanyAndUsersId());
} else {
$myBranchId = Auth::user()->employee->branch_id ?? null;
$myBranchId = Auth::user()->branch_id ?? Auth::user()->employee->branch_id ?? null;
if ($myBranchId) {
$query->whereHas('employee', function ($q) use ($myBranchId) {
$q->where('branch_id', $myBranchId);