Skip to content

Instantly share code, notes, and snippets.

Created April 21, 2014 05:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/11133373 to your computer and use it in GitHub Desktop.
Save anonymous/11133373 to your computer and use it in GitHub Desktop.
<?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