/** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { $formats = Format::all(); $categories = Category::all(); $output = array('formats' => $formats, 'categories' => $categories); return view('user.addBook', compact('output')); }
/** * 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); }
/** * @return mixed */ public function all() { return Format::all(); }