Last active
September 16, 2017 10:08
-
-
Save akmandev/dafe2497f638069332125bb3b157c033 to your computer and use it in GitHub Desktop.
Laravel - sortBy Multiple Columns
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
<?php | |
// Laravel collections - sorting by multiple columns; | |
$collection->sortBy(function ($post) { | |
return sprintf('%s%s', $post->column, $post->relation->column); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment