php - I need help in laravel 6 (search by name specialty and country in the same time)
575
I always get an error (Undefined nom) when I press the button of Search , I need someone who can solve this problem with me and correct my code: so this is my code :
Controller: doctors.php
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\doctor;
class doctors extends Controller
{
//
function afficher()
{
$data=doctor::all();
if ($data['nom']==$request->get("rech") && $data["spécialité"]==$request->get("spes") )
{
echo "voila la liste .$data.";
}else{
echo "not found";
}
}
and this is the form: acceuil.blade.php
<form action="/doctors" method="GET">
<div>
<div >
<div >
<input type="text" placeholder="Tapez le nom de votre médecin" name="rech" value="">
</div>
<div z-index=1px>
<select type="text" placeholder="Spécialité" name="spes">
<option value="" disabled selected>Choisir la spécialité</option>
<option value="1">Généraliste</option>
<option value="2">Cardiologue</option>
<option value="3">Pédiatre</option>
<option value="3">Psychiatre</option>
<option value="3">Gynécologue</option>
</select>
</div>
<div >
<select type="text" placeholder="" name="ville" >
<option value="" disabled selected>Région</option>
<option ... >
</select>
</div>
<div >
<input type="submit" value="RECHERCHER" >
</div>
</div>
</form>
Answer
Solution:
Assuming you are having
nom
andspécialité
column in your tabledoctors
. If you want to fetch the data on behalf of thedoctor
model, then the query will be.Hope this will works for you.