These films come from The Movie Database (TMDB). Here is the real PHP I wrote to fetch and filter them.
public function __construct() { $this->apiUrl = config('tmdb.api_url'); $this->apiToken = config('tmdb.api_token'); }
private function fetchMovies($page = 1, $excludedWords = []) { $response = Http::withToken($this->apiToken) ->get("{$this->apiUrl}/discover/movie", [ 'language' => 'en-US', 'page' => $page, 'with_genres' => '10751' ]); $movies = $response->json(); // Filter out movies containing any of the excluded words $filtered = array_filter($movies['results'] ?? [], function ($movie) use ($excludedWords) { $title = strtolower($movie['title'] ?? $movie['name'] ?? ''); foreach ($excludedWords as $word) { if (strpos($title, strtolower($word)) !== false) { return false; } } return true; }); // Pagination logic $moviesPerPage = 8; $totalMovies = count($filtered); $startIndex = ($page - 1) * $moviesPerPage; return array_slice($filtered, $startIndex, $moviesPerPage); }
private function fetchChristianMovies($page = 1) { $response = Http::withToken($this->apiToken) ->get("{$this->apiUrl}/list/8938", [ 'language' => 'en-US', 'page' => $page ]); return $response->json(); }
private function fetchRecommendations($id) { $response = Http::withToken($this->apiToken) ->get("{$this->apiUrl}/movie/{$id}/recommendations"); return $response->json(); }