Reputation: 1354
Currently trying to paginate some results on a product object.
The paginate object that I am receiving in my view {{ $products->links() }}
is returning correctly however instead of the query being "test.com/search?search=test&page2" it is returning "test.com/search?query=test&page2" how can i change it so it returns search instead of query?
The html output is:
<a href="http://test.dev/search?query=test&page=2">2</a>
but what i need is:
<a href="http://test.dev/search?search=test&page=2">2</a>
EDIT: Controller:
public function searchable(Request $request)
{
// search database, with result, list on page, with links to products,
$products = Product::search($request->search)->paginate(3);
return view('search.index', compact('products', 'request'));
}
use Laravel\Scout\Searchable;
use Illuminate\Database\Eloquent\Model;
use Carbon\Carbon;
class Product extends Model
{
use Searchable;
/**
* Creates searchable index for product model
* @return [type] [description]
*/
public function searchableAs()
{
return 'products_index';
}
}
form:
{{ Form::open(array('url' => '/search', 'method' => 'GET', 'files' => 'false')) }}
<div class="row">
<div class="col-md-2">
<button type="submit" class="custom-search-button btn btn-lrg btn-primary">Search</button>
</div>
<div class="col-md-10">
<input class="search-bar" type="search" name="search" placeholder="type keyword(s) here" />
</div>
</div>
{{-- <input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/> --}}
{{ Form::close() }}
Upvotes: 2
Views: 929
Reputation: 1282
You have field named query
in your search form. Change its name to search
, adjust logic in controller to be using search
param instead of query
and you are done.
Upvotes: 1