Implement HR Branch isolation and Shift isolation
This commit is contained in:
@@ -22,7 +22,7 @@ class LeaveBalanceController extends Controller
|
||||
if (Auth::user()->can('manage-any-leave-balances')) {
|
||||
$q->whereIn('created_by', getCompanyAndUsersId());
|
||||
} elseif (Auth::user()->can('manage-leave-balances')) {
|
||||
$branchId = Auth::user()->employee->branch_id ?? null;
|
||||
$branchId = Auth::user()->branch_id ?? Auth::user()->employee->branch_id ?? null;
|
||||
if ($branchId) {
|
||||
$q->whereHas('employee.employee', function ($eq) use ($branchId) {
|
||||
$eq->where('branch_id', $branchId);
|
||||
@@ -125,7 +125,7 @@ class LeaveBalanceController extends Controller
|
||||
$employeeQuery = Employee::whereIn('created_by', getCompanyAndUsersId());
|
||||
|
||||
if (Auth::user()->can('manage-leave-balances') && !Auth::user()->can('manage-any-leave-balances')) {
|
||||
$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 {
|
||||
|
||||
Reference in New Issue
Block a user