Wednesday 19 February 2020

SQL && Laravel eloquent order by multiple column

User::orderBy('name', 'DESC')
    ->orderBy('email', 'ASC')
    ->get();
Produces the following query:
SELECT * FROM `users` ORDER BY `name` DESC, `email` ASC

https://stackoverflow.com/questions/17006309/how-to-use-order-by-for-multiple-columns-in-laravel-4

No comments:

Post a Comment