Last active
August 22, 2016 18:59
-
-
Save SabrinaMarkon/916e3a3ed0c4d7c2d188a70bb16ada5b to your computer and use it in GitHub Desktop.
Sabrina Notes - Laravel 5.2 - Eloquent - How to order database SELECT results by multiple columns
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Laravel 5.2 - Eloquent - How to order database SELECT results by multiple columns | |
--------------------------------------------------------------------------------- | |
Chain together using orderBy with the columns being sorted in the order they are chained, as in the example line below: | |
$contents = ModelName::orderBy('columnA', 'asc')->orderBy('columnB', 'desc')->get(); | |
If $contents is returned to the view now, all rows of the table will be sorted first according to the ascending values of | |
columnA, followed by a second sort of the desc values of column B. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment