laravel order by desc Query Builder

Today, We want to share with you laravel order by desc Query Builder.In this post we will show you Eloquent latest(), add orderby id on top of order, hear for laravel raw query with parameters we will give you demo and example for implement.In this post, we will learn about Using OrderBy for multiple columns in Laravel 4/5/6/7 with an example.

laravel order by desc Query Builder

There are the Following The simple About Adding Multiple OrderBy clause in Laravel Full Information With Example and source code.

Read Also:  Laravel Resize Image Before Upload Example

As I will cover this Post with live Working example to develop Laravel Quick Tip: orderByRaw() with ORDERBY, so the Database: Query Builder is used for this example is following below.

Eloquent sort query Laravel

By DESC order

$doctors = DB::table('doctors')->orderBy('doctor_name', 'desc')->get();

By ASC order

$doctors = DB::table('doctors')->orderBy('doctor_name', 'asc')->get();

Using OrderBy for multiple columns in Laravel

multiple columns using Laravel

Doctor::orderBy('doctor_name', 'DESC')
->orderBy('hospital_name', 'ASC')

SQL Query

SELECT * FROM `doctors` ORDER BY `doctor_name` DESC , `hospital_name` ASC , `address` ASC;

pass it as an array

Doctor::orderBy(array('doctor_name'=>'desc', 'hospital_name'=>'asc'))

Using OrderByRaw will also produce the same result.

Read Also:  Laravel Database Eloquent Unions Query

Doctor::orderBy(array('doctor_name'=>'desc', 'hospital_name'=>'asc'))

Web Programming Tutorials Example with Demo

Read :


You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Using OrderBy for multiple columns in Laravel 4/5/6/7.
I would like to have feedback on my blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.