Implement HR Branch isolation and Shift isolation
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user