Skip to content

Instantly share code, notes, and snippets.

@iamdtang
Last active February 2, 2016 07:40
Show Gist options
  • Save iamdtang/c62b0d857f8437378a15 to your computer and use it in GitHub Desktop.
Save iamdtang/c62b0d857f8437378a15 to your computer and use it in GitHub Desktop.
handling All dropdowns
$genre = $request->input('genre');
$movies = DB::table('dvds')
->select('title', 'genre_name', 'rating_name', 'label_name', 'sound_name', 'format_name')
// more joins here
->join('genres', 'dvds.genre_id', '=', 'genres.id');
if ($genre !== 'All') {
$movies = $movies->where('genre_id', '=', $genre);
}
$movies = $movies->get();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment