I have an issue in my search box, I actually want to show products on a page when anyone searches for the similar product but I am just getting a header and footer not any product.
This is my query in the controller
public function showsearchpage()
{
$query = Product::where('product_name','LIKE','%$q%');
return view('search', ['searchbox'=>$query]);
}
and this is my search.blade.php
view source code that I want to show up on my search page
@foreach($searchbox as $query)
<div class="iso-box photoshop branding col-md-4 col-sm-6">
<div class="portfolio-thumb">
<img src="images/portfolio-img1.jpg" class="img-responsive" alt="Portfolio">
<div class="portfolio-overlay">
<div class="portfolio-item">
<a href="/categoriesViewPost"><i class="fa fa-link"></i></a>
<h2>{{$query->product_name}}</h2>
<p>{{$query->product_description}}</p>
</div>
</div>
</div>
</div>
@endforeach
And this is the screenshot that I am getting (I have a similar product in my database of product but still its showing nothing):
3
Answers
You forgot get();
problems :
‘%$q%’
->get();