public function getAlerts($request) { $patient_ids = array(); $today = Carbon::now(); $today->hour = 0; $today->minute = 0; $today->second = 0; $tomorrow = $today->copy()->addDay(); if ($request->session()->get('global_branch') == 'all') { foreach (Appointment::whereIn('status_id', [3, 4])->where('start_date', '>', $today)->where('end_date', '<', $tomorrow)->get() as $a) { $patient_ids[] = $a->patient_id; } } else { foreach (Appointment::whereIn('status_id', [3, 4])->where('branch_id', $request->session()->get('global_branch'))->where('start_date', '>', $tomorrow)->where('end_date', '<', $today)->get() as $a) { $patient_ids[] = $a->patient_id; } } $alerts = new Collection(); if (count($patient_ids) > 0) { foreach ($patient_ids as $id) { $patient = Patient::findOrFail($id); if ($patient->hasAlert()) { $alerts->push($patient->getAlert()); } } } view()->share('alerts', $alerts); }
private function getAppointments($expression) { $this->results['appointments'] = Appointment::whereIn('business_id', $this->scope['businessesIds'])->where('hash', 'like', $expression . '%')->get(); }