Created
April 21, 2014 05:46
-
-
Save anonymous/11133373 to your computer and use it in GitHub Desktop.
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
<?php | |
class HomeController extends BaseController { | |
public function getIndex() { | |
$collection = Auth::user()->items; | |
$collection->sort(function($a, $b) { | |
$a = $a->time; | |
$b = $b->time; | |
if ($a === $b) { | |
return 0; | |
} | |
// returning sorted objects from auth user | |
return ($a > $b) ? 1 : -1; | |
}); | |
// passing sorted array to home view | |
return View::make('home', array('items' => $collection)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment