I’m working on a project which is a search engine for TV series. On the first page you can choose genres, release year, actors, etc. The site goes through the db and lists out all series matching the users criteria. I now want the users to be able to sort through the result by ‘A-Z’, ‘Oldest’ and ‘Newest’.
So far by adding a hidden input in the form I’m able to order the result by title, and if I manually change the sort value in the url it works, but how can I make it happen automatically when for instances a user presses a link or a button?
This is the start of my form:
{!! Form::open(array('route' => 'result', 'method' => 'GET')) !!}
{!! Form::hidden('sort', 'title') !!}
This where I get the sort variable from the URL:
OrderBy((Input::get('sort')), 'asc')->paginate(10);
You can just pass in the variables like a normal route. However make sure your route does not accept any parameters. If your does not accept any parameters Laravel will add them like a GET request.