/** * Display a listing of the resource. * * @return Response */ public function index($sort = null) { if ($sort == 'category') { $movies = Movie::orderBy('category_id')->get(); $movies = $movies->sortBy(function ($movie) { return $movie->category->name . $movie->title; }); } elseif ($sort == 'format') { $movies = Movie::orderBy('format')->orderBy('title')->get(); } else { $movies = Movie::orderBy('title')->get(); } $with['movies'] = $movies; $with['formats'] = Format::all(); $with['categories'] = Category::all(); return \View::make('movie.list')->with($with); }
public function weekSix() { $movies = Movie::orderBy('ranking', 'asc')->get(); return view('coursework.week_six.index', ['movies' => $movies]); }