Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

OzzyBoy's avatar

Laravel List by Date by Price , Price Desc

i have search result page for a home/car seller website , it a listing page . There are some options on html template like :

order by data , price , price desc. I should order results by clicking this options. Client doesnt want to use datatables. How can i implement it ! i know how to fetch data with laravel

DB::table('')->orderBy('', '')->get(); But i couldnt understand the logic. Because after i come to search result page with data , how can i take query and change the order at current page ?

Or is there a technic for that ?

0 likes
3 replies
davidfaux's avatar

The only technique you can use on page (i.e. without reloading the page) will be javascript, be it jQuery or something like Angular.

OzzyBoy's avatar

Thank you , but my first request for search in search page and results in results page. i can do ajax in results page but how will take the same search query and send it from result page to controller for ordering ?

davidfaux's avatar

Perhaps something like:

<a href="{{ url('search', ['name', 'asc']) }}">▲</a>

Which should create a url like http://www.example.com/search/name/asc which can be routed to and dealt with by the controller. This is just an example, you could also use HTTP GET variables e.g. search?orderby=name&order=asc

Please or to participate in this conversation.