start_date)){ $start_date = Carbon::createFromFormat('d/m/Y', $request->start_date)->toDateString(); $end_date = Carbon::createFromFormat('d/m/Y', $request->end_date)->toDateString(); } else { $start_date = Carbon::now()->startOfDay()->toDateTimeString(); $end_date = Carbon::now()->endOfDay()->toDateTimeString(); } $prescription_errors = DB::table('prescription_errors')->orderBy('created_at', 'desc') ->whereBetween('created_at', [$start_date, $end_date]) ->paginate(1000); $search_text = "Searching between " . streamline_date($start_date) . " and " . streamline_date($end_date); return view('pharmacy::prescription_errors.index', compact('prescription_errors', 'search_text')); } public function view_prescription_error_details($id){ $prescription_error = PrescriptionError::find($id); if (!$prescription_error){ return back()->withInput(); } $altered_drugs_array = array( "drugs" => $prescription_error->previous_drugs, "dose" => $prescription_error->previous_doses, "drug_frequency" => $prescription_error->previous_frequencies, "instructions" => $prescription_error->previous_instruction, "duration" => $prescription_error->previous_durations, "quantity_dispensed" => $prescription_error->previous_quantities_dispensed, ); $prescribed_drugs = Treatment::find($prescription_error->treatment_id); if (!$prescribed_drugs){ return back()->withInput(); } $prescribed_drugs_array = array( "drugs" => $prescribed_drugs->drugs, "dose" => $prescribed_drugs->doses, "drug_frequency" => $prescribed_drugs->frequencies, "instructions" => $prescribed_drugs->instruction, "duration" => $prescribed_drugs->durations, "quantity_dispensed" => $prescribed_drugs->quantities_dispensed, ); return view('pharmacy::prescription_errors.view_prescription_error_details', compact('prescription_error', 'prescribed_drugs_array', 'altered_drugs_array')); } }