Order by is used to sort sql results by column names. In this example we will see how to add multiple orderby clause in Laravel.
Let take an example we have a users table and we want to sort results by name of user, then here is query to do that in Laravel.
The above Eloquent query return all user those status is active in sorted ascending order by name. To sort in descending order use orderBy('name','DESC').
Similarly you can add as many order by clause in Laravel. Here is an example.
This post is submitted by one of our members. You may submit a new post here.