@php use Carbon\Carbon; $revisedDayEndPendingBranches = []; $branchSoftStartDates = DB::table('gnr_branch')->pluck('softwareStartDate', 'branchCode')->all(); $branchIdCodeArr = DB::table('gnr_branch')->pluck('id', 'branchCode')->all(); foreach($dayEndPendingBranches as $pendingBranch){ $code = (int)explode('-', $pendingBranch)[0]; $softwareStartDate = $branchSoftStartDates[$code]; if(Carbon::parse($softwareStartDate)->lte(Carbon::parse($data['filDate']))){ if(!isHoliday($data['filDate'], $branchIdCodeArr[$code])){ $revisedDayEndPendingBranches[] = $pendingBranch; } } } $dayEndPendingBranches = $revisedDayEndPendingBranches; $dayEndPendingBranches = array_diff($dayEndPendingBranches, ['000 - Head Office', '400 - Project Office', '100 - Bhaberchar- Gri', '100 - Gazaria- Gri']); function isHoliday($date,$targetBranchId){ $date = Carbon::parse($date)->format('Y-m-d'); $isHoliday = 0; //get holidays $holiday = (int) DB::table('mfn_setting_holiday')->where('softDel',0)->where('status',1)->where('date',$date)->value('id'); if ($holiday>0) { $isHoliday = 1; } // get the organazation id and branch id of the logged in user if ($isHoliday!=1) { $userBranchId = Auth::user()->branchId; $userOrgId = Auth::user()->company_id_fk; if($targetBranchId!=1){ $userBranchId = $targetBranchId; $userOrgId = DB::table('gnr_branch')->where('id',$targetBranchId)->value('companyId'); } $holiday = (int) DB::table('mfn_setting_orgBranchSamity_holiday') ->where('status',1) ->where('softDel',0) ->where(function ($query) use ($userBranchId,$userOrgId) { $query->where('ogrIdFk', '=', $userOrgId) ->orWhere('branchIdFk', '=', $userBranchId); }) ->where('dateFrom','<=',$date) ->where('dateTo','>=',$date) ->value('id'); if($holiday>0){ $isHoliday = 1; } } return $isHoliday; } @endphp @if (isset($dayEndPendingBranches)) @if (count($dayEndPendingBranches)>0)