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 .
abc.com/search/q=res
Here is my routes :
Route::post('productSearch','ProductController@productSearch');
Route::get('search/q={query}','ProductController@searchProduct');
public function productSearch(Request $request)
{
$query = $request->name;
return redirect('search/q='.$query);
}
public function searchProduct(Request $request)
{
$name = $request->query;
$products = DB::table('products')
->select('products.*')
->where('products.name' , 'like', '%'.$name.'%') //Error in this line
return view('product',compact('products'));
}
But the problem is it shows the following Error
Object of class Symfony\Component\HttpFoundation\ParameterBag could not be converted to string
How do i implement search where in URL in shows in this way?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire