title: Invalid entry in my search bar in Laravel
body: <p>I created a search bar, it works well so far. I would like to improve my search bar. </p>
  
  <p>When I enter a name which is not in my listing I will wish to stay on my page index with all the recordings.</p>
  
  <p>For example: If I enter <code>leonard</code> as name </p>
  
  <p><a href="https://i.stack.imgur.com/2WMwy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2WMwy.png" alt="enter image description here"></a></p>
  
  <p>I have a page empty...</p>
  
  <p><a href="https://i.stack.imgur.com/er5nR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/er5nR.png" alt="enter image description here"></a></p>
  
  <p>Is it possible to stay on my page index with my recordings ?</p>
  
  <p>Here's my relevant code:</p>
  
  <pre><code>public function index(Request $req)
  {
     if ($req-&gt;has('search') &amp;&amp; !empty($req-&gt;search)) {
          $validated = $req-&gt;validate([
          'search' =&gt; 'alpha', 
          ]);
  
          $students = Student::where('name', 'LIKE', '%' . $validated['search'] . '%')-&gt;orderBy('name', 'ASC')-&gt;paginate(5);
          $students-&gt;appends($req-&gt;only('search'));
          return view('admin.students.index', compact('students'));
          }
  
          $students = Student::orderBy('name', 'ASC')-&gt;paginate(5);
          return view('admin.students.index', compact('students'));
  }
  </code></pre>