Using OrderBy for multiple columns in Laravel 4

When you want to sort multiple columns of a table in Laravel you can use OrderBy(). You should use OrderBy as many times as you need it in the query.

 An example is given below.

User::orderBy('name', 'DESC')

    ->orderBy('email', 'ASC')

   ->orderBy('address','ASC')

    ->get(); 

This will produce the query

SELECT  *  FROM  `user`  ORDER BY `name`  DESC , `email`  ASC , `address`  ASC;

You can also pass it as an array.
User::orderBy(array('name'=>'desc', 'email'=>'asc'))
Using OrderByRaw will also produce the same result.

MyTable::orderByRaw("coloumn1 DESC, coloumn2 ASC"); 

->get();