title: multiple search from database in laravel
body: <p>I want to search data from database and show in my laravel blade.
  here is my controller</p>
  <pre><code> $results = ClassModel::query();
   $results-&gt;when(request('student_id'), function($q){
        $q-&gt;where('student_id', request('student_id'));
      })
      -&gt;when(request('student_name'),function($q){
        $q-&gt;orWhere('student_name', request('student_name'));
      })
      -&gt;when(request('subject'), function($q){
        $q-&gt;orWhere('subject', request('subject'));
      })
      -&gt;when(request('teacher_name'), function($q){
        $q-&gt;orWhere('teacher_name', request('teacher_name'));
      })
      -&gt;when(request('class'), function($q){
        $q-&gt;orWhere('class', request('class'));
      });
      $records = $results-&gt;get();
      return view('class.index')-&gt;with('class', $records);
          
  
     
  </code></pre>
  <p>it works ok with few filters when I add all multiple filters it returns me empty array , I don't know why .Is that method fine or should I try any other method ?</p>