email; $receiveDataEmail = User::where('email', $userEmail)->first(); $receiveDataWs = ConstructionWorkstation::where('name_workstations', $receiveDataEmail->user_name)->first(); $receiveAllEquipmentOfProject = Equipment::where('company_projects_id', $receiveDataWs->company_projects_id) ->whereHas('equipmentWorkHistory', function ($query) use ($receiveDataWs) { $query->where('company_projects_id', $receiveDataWs->company_projects_id); }) ->whereDoesntHave('equipmentWorkHistory.controlEquipmentWorkstation', function ($query) { $query->whereNull('elemental_tasks_id') ->whereNull('departure_date'); }) ->get(); $receiceCountAllEquipmentOfProject = count($receiveAllEquipmentOfProject); //Returning values of the queries to workstations layout $view->with([ 'receiveAllEquipmentOfProject' => $receiveAllEquipmentOfProject, 'receiceCountAllEquipmentOfProject' => $receiceCountAllEquipmentOfProject, 'receiveDataWs' => $receiveDataWs, ]); } }