title: Implementing Search with Laravel
body: <p>I was trying to implement search with laravel where i want to submit the form with post method and trying to show the query like this . </p>
  
  <pre><code>abc.com/search/q=res
  </code></pre>
  
  <p>Here is my routes :</p>
  
  <pre><code>Route::post('productSearch','ProductController@productSearch');
    Route::get('search/q={query}','ProductController@searchProduct');
  
  public function productSearch(Request $request)
      {
          $query = $request-&gt;name; 
          return redirect('search/q='.$query);
      }
  
      public  function searchProduct(Request $request)
      {
          $name = $request-&gt;query;
          $products = DB::table('products')           
              -&gt;select('products.*')              
              -&gt;where('products.name' , 'like', '%'.$name.'%') //Error in this line   
  
          return view('product',compact('products'));
      }
  </code></pre>
  
  <p>But the problem is it shows the following Error </p>
  
  <pre><code>Object of class Symfony\Component\HttpFoundation\ParameterBag could not be converted to string
  </code></pre>
  
  <p>How do i implement search where in URL in shows in this way?</p>