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.
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') ->orderBy('address','ASC') ->get();
SELECT * FROM `doctors` ORDER BY `doctor_name` DESC , `hospital_name` ASC , `address` ASC;
pass it as an array
Using OrderByRaw will also produce the same result.
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 infinityknow.com 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.
Here are some more FAQ related to this Article: