Answer the question
In order to leave comments, you need to log in
How to find by model if the model is not complete?
On the main page there is a Request that receives data from the form
public function index(Request $request)
{
if ($request->surname != null || $request->first_name != null || $request->second_name != null || $request->birthday != null) {
$patient = new Patient();
$patient->surname = $request->surname;
$patient->first_name = $request->first_name;
$patient->second_name = $request->second_name;
$patient->birthday = $request->birthday;
$patients = Patient::orWhere('surname', $patient->surname)
->orWhere('first_name', $patient->first_name)
->orWhere('second_name', $patient->second_name)
->orWhere('birthday', $patient->birthday)
->get();
return view('staff_doctor.patient.index', compact('patients', 'patient'));
} else {
$patients = Patient::all()->sortBy('surname')->sortBy('first_name')->sortBy('second_name')->sortBy('birthday');
return view('staff_doctor.patient.index', compact('patients'));
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question