Answer the question
In order to leave comments, you need to log in
Search filter based on GET parameters in laravel?
While implementing a filter on the search page based on GET parameters, I ran into the problem of generating a url address for the filter buttons. In order to save the current search parameters, I do this:
<a href="/search?{{($request->q ? "q=$request->q" : '') . ($request->sort ? "&sort=$request->sort" : '') . "§ion=photoreports"}}">Фоторепортажи</a>
Answer the question
In order to leave comments, you need to log in
One of the options:
route(
'route.name',
array_merge(
request()->query(),
[
'sortBy' => 'relevance_score',
'sortOrder' => ($currentSortBy === 'relevance_score' && $currentSortOrder === 'asc') ? 'desc' : 'asc',
]
)
)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question