public function getBrowse($category) { //Get browse category $category_filtered = strtoupper(trim($category)); //Page Title $data['title'] = $category_filtered; //Switch to get appropriate data, redirect to error if options aren't listed switch ($category_filtered) { case 'SERIES': $data['comics'] = Comicbooks::orderBy('book_name', 'asc')->get(); break; case 'AUTHORS': $data['comics'] = Authors::select('author_name')->orderBy('author_name', 'asc')->distinct()->get(); break; case 'ARTISTS': $data['comics'] = Artists::select('artist_name')->orderBy('artist_name', 'asc')->distinct()->get(); break; case 'CHARACTERS': $data['comics'] = Characters::select('character_name')->orderBy('character_name', 'asc')->distinct()->get(); break; case 'PUBLISHERS': $data['comics'] = Publishers::select('publisher_name')->orderBy('publisher_name', 'asc')->distinct()->get(); break; case 'GENRES': $data['comics'] = Genres::orderBy('genre_name', 'asc')->get(); break; case 'YEARS': //This needed to be a raw query because of the date $data['comics'] = Comicissues::select(DB::raw('year(published_date) as year'))->orderBy('published_date', 'asc')->distinct()->get(); break; default: return Redirect::to('error'); break; } $this->layout->content = View::make('browse', $data); }