Trying to set up basic search functionality for products. I am having trouble sorting the route parameter variable and passing the query string to the search function.
Route::get('/search/{query?}', 'ProductController@searchable');
This works and returns a query when I input the query manually.
Controller
public function searchable($query)
{
// search database, with result, list on page, with links to products,
$products = Product::search($query)->get();
return view('search.index', compact('products'));
}
However, I would like it to come from the URL /search?test
.
My form shows:
{{ Form::open(array('action' => 'ProductController@searchable', 'method' => 'get', 'files' => 'false')) }}
<input type="search" name="search" placeholder="type keyword(s) here" />
<button type="submit" class="btn btn-primary">Search</button>
{{ Form::close() }}`
I am new to Laravel and need a little help. I am using Laravel Scout and TNTSearch.