Last active
September 12, 2016 19:33
-
-
Save tanftw/627da69cb05e6abf104e201f6ff69883 to your computer and use it in GitHub Desktop.
orderByRaw() Laravel
This file contains hidden or 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
// Usage: When you need, for example order by sticky post and updated_at | |
Post::orderByRaw(\DB::raw("CASE `status` WHEN 'sticky' THEN 1 ELSE 2 END")) | |
->orderBy('updated_at', 'desc') | |
->paginate(15); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment