fix: make HR shift stats match the table query so counts are accurate
This commit is contained in:
@@ -70,10 +70,16 @@ class ShiftController extends Controller
|
||||
$allShifts = Shift::where(function ($q) {
|
||||
if (Auth::user()->can('manage-any-shifts')) {
|
||||
$q->whereIn('created_by', getCompanyAndUsersId());
|
||||
} elseif (Auth::user()->can('manage-own-shifts')) {
|
||||
$q->where('created_by', Auth::id());
|
||||
} else {
|
||||
$q->whereRaw('1 = 0');
|
||||
$branchId = Auth::user()->branch_id ?? Auth::user()->employee->branch_id ?? null;
|
||||
if ($branchId) {
|
||||
$q->where(function($q2) use ($branchId) {
|
||||
$q2->where('branch_id', $branchId)
|
||||
->orWhereNull('branch_id'); // company wide shifts
|
||||
})->whereIn('created_by', getCompanyAndUsersId());
|
||||
} else {
|
||||
$q->whereIn('created_by', getCompanyAndUsersId());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user