public function filterMovies() { if (Request::ajax()) { $data = Request::all(); $type = $data['type']; $search_string = trim($data['val']); if ($search_string != "") { $query = Movies::select('movies.*'); switch ($type) { case "all": $query->where('name', 'LIKE', '%' . $search_string . '%'); break; case "studio": $query->where('studios.name', 'LIKE', '%' . $search_string . '%')->join('studios', 'movies.studio_id', '=', 'studios.studio_id'); break; case "format": $query->where('formats.type', 'LIKE', '%' . $search_string . '%')->join('formats', 'movies.format_id', '=', 'formats.format_id'); break; case "certificate": $query->where('certificate_id', $search_string); break; case "year": $query->where('released', $search_string); break; case "rating": $query->where('rating', $search_string); break; case "tag": $query->where('keywords.word', 'LIKE', '%' . $search_string . '%')->join('tags', 'movies.movie_id', '=', 'tags.movie_id')->join('keywords', 'keywords.keyword_id', '=', 'tags.keyword_id'); break; } $query->orderBy('sort_name'); $movies = $query->get(); if ($type == "all") { $people = Persons::where(DB::raw("CONCAT(`forename`, ' ', `surname`)"), 'LIKE', '%' . $search_string . '%')->orderBy('forename')->get(); } else { $people = []; } $user = $this->isAdmin; $quote = count($movies) ? "" : $this->getRandomQuote(); return (string) view('ajax.movie_filter', compact('movies', 'people', 'quote', 'user')); } else { return "blank"; } } }
public static function selectRandomFilm() { $movie_ids = Movies::select('movie_id')->where('bio', '!=', '')->has('cast')->get()->toArray(); $selected_movie = array_rand($movie_ids, 1); return $selected_movie; }
public function movieRatingCount() { $movies = []; $ratings = []; $query = Movies::select('rating', DB::raw('count(*) as count'), 'rating as id')->groupBy('rating')->get(); foreach ($query as $result) { $movies[$result->rating] = $result->count; } for ($x = 1; $x <= 10; $x++) { $rating = []; $rating['label'] = $x; $rating['y'] = isset($movies[$x]) ? $movies[$x] : 0; $ratings[] = $rating; } return $ratings; }
/** * * Show form to edit an existing person record * @param integer $person_id * @return Response * */ public function edit($person_id) { if (!$this->isAdmin) { return view('auth.login'); } $person = Persons::findorfail($person_id); $person->cover = $this->checkImageExists($person->image, $person->forename, 'people'); $person->cover_count = strlen($person->cover); $person->birthday = $this->formatDate($person->birthday, 'output'); $person->deceased = $this->formatDate($person->deceased, 'output'); $fields = Forms::getFormFields('create_person', true); $values = json_decode($person); $user = $this->isAdmin; $app = app(); $options = $app->make('stdClass'); $options->movies = Movies::select('name', 'movie_id')->whereNotIn('movie_id', function ($query) use($person_id) { $query->select('movie_id')->from('cast')->where('person_id', $person_id); })->orderBy('name')->lists('name', 'movie_id')->all(); return view('people.edit', compact('person', 'fields', 'values', 'options', 'user')); }
public function filterMovies($request) { $data = $request->all(); $search_string = trim($data['val']); if ($search_string != "") { $movies = Movies::select('movies.*')->where('name', 'LIKE', '%' . $search_string . '%')->orderBy('sort_name')->get(); $people = Persons::where(DB::raw("CONCAT(`forename`, ' ', `surname`)"), 'LIKE', '%' . $search_string . '%')->orderBy('forename')->get(); $user = $this->isAdmin; $quote = count($movies) ? "" : $this->getRandomQuote(); return view('ajax.movie_filter', compact('movies', 'people', 'quote', 'user')); } }