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.

Read Also:  Handle CORS Requests in Laravel 6 Application

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')

SQL Query

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

pass it as an array

Read Also:  Double Click (ng-dblclick) using Angular Example

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

Using OrderByRaw will also produce the same result.

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.

Read Also:  Dropdown ng-change Event using Angular Example

Related FAQ

Here are some more FAQ related to this Article:

  1. Read Also:  PHP Laravel 7 Inner Join Query Example (join query in laravel)
  2. Read Also:  $interval Service using Angular Example
  3. Read Also:  Session Management in CodeIgniter with PHP
  4. Read Also:  How to create custom PHP page-Template using WordPress
  5. Read Also:  Eloquent orwhere Query Use in Laravel
  6. Read Also:  laravel join Multiple Tables using Model Example
  7. Read Also:  Laravel Advance Database Query Builder
  8. Read Also:  Laravel 6 try catch Database Transaction
  9. Read Also:  String Methods List using JavaScript Example
  10. Read Also:  laravel db Raw SQL Queries select insert and Update