Implement HR Branch isolation and Shift isolation
This commit is contained in:
@@ -197,6 +197,12 @@ class EmployeeController extends Controller
|
||||
|
||||
$shifts = \App\Models\Shift::whereIn('created_by', getCompanyAndUsersId())
|
||||
->where('status', 'active')
|
||||
->where(function($q) {
|
||||
$branchId = Auth::user()->branch_id ?? Auth::user()->employee->branch_id ?? null;
|
||||
if ($branchId && !Auth::user()->can('manage-any-shifts')) {
|
||||
$q->where('branch_id', $branchId)->orWhereNull('branch_id');
|
||||
}
|
||||
})
|
||||
->get(['id', 'name', 'start_time', 'end_time']);
|
||||
|
||||
$attendancePolicies = \App\Models\AttendancePolicy::whereIn('created_by', getCompanyAndUsersId())
|
||||
@@ -520,6 +526,12 @@ class EmployeeController extends Controller
|
||||
|
||||
$shifts = \App\Models\Shift::whereIn('created_by', getCompanyAndUsersId())
|
||||
->where('status', 'active')
|
||||
->where(function($q) {
|
||||
$branchId = Auth::user()->branch_id ?? Auth::user()->employee->branch_id ?? null;
|
||||
if ($branchId && !Auth::user()->can('manage-any-shifts')) {
|
||||
$q->where('branch_id', $branchId)->orWhereNull('branch_id');
|
||||
}
|
||||
})
|
||||
->get(['id', 'name', 'start_time', 'end_time']);
|
||||
|
||||
$attendancePolicies = \App\Models\AttendancePolicy::whereIn('created_by', getCompanyAndUsersId())
|
||||
|
||||
Reference in New Issue
Block a user