php - I need help in laravel 6 (search by name specialty and country in the same time)


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


    namespace App\Http\Controllers;

    use Illuminate\Http\Request;

    use App\doctor;

    class doctors extends Controller
        function afficher()
            if ($data['nom']==$request->get("rech") && $data["spécialité"]==$request->get("spes") ) 
                echo "voila la liste .$data.";   
                echo "not found";

and this is the form: acceuil.blade.php

<form action="/doctors" method="GET">
  <div >
    <div >
      <input type="text" placeholder="Tapez le nom de votre médecin" name="rech" value="">
  <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> 
  <div >
    <select type="text" placeholder="" name="ville" > 
      <option value="" disabled selected>Région</option>
      <option ... >
  <div >
    <input type="submit" value="RECHERCHER" >



Assuming you are havingnom andspécialité column in your tabledoctors. If you want to fetch the data on behalf of thedoctor model, then the query will be.

    $result = doctor::where('nom', $request->rech)
                  ->where('spécialité', $request->spes)

Hope this will works for you.

People are also looking for solutions to the problem: php - Restrict duplication in single input field


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.