title: Search Returns All Data in Database while using Laravel APi
body: <p>I am working on an API with Laravel, I  want to be able to search using the API, but I am unable to
  Here is my method</p>
  
  <pre><code>   public function searchapi()
     {
  
   $search = request()-&gt;get('search');
  
     /* $books = Book::when($search, function ($query, $search) {
         return $query-&gt;where('name', 'LIKE', "%{$search}%");
     })
      -&gt;orderBy('created_at', 'desc')
      -&gt;simplepaginate(12); */
  
    $books = Book::where('name', 'LIKE', "%{$search}%")-&gt;Paginate(16);
    $author = Author::where('name', 'LIKE', "%{$search}%")-&gt;Paginate(16);
    $genre = Category::where('title', 'LIKE', "%{$search}%")-&gt;Paginate(16);
  
  
  
     return Response::json(array(
      'books' =&gt; $books, 
      'author'=&gt;$author,
      'genre'=&gt;$genre,
   ));
  
  
  }
  </code></pre>
  
  <p>I don't know what I am doing wrong as this returns all the data in the database when search using postman.</p>
  
  <p>My route in api.php</p>
  
  <pre><code>Route::get('/search', 'BooksController@searchapi');
  </code></pre>
  
  <p><H1>UPDATE</H1>
  I am using post man to test. I passed <code>Key=search</code> and <code>value=searchterm</code></p>