getShow($id); $airing = $this->formatTmdbResponse($tmdb->getAiringShows(1), false, [], 12)['data']; return $data; }; $results = $call(); // Cache::remember(implode('__', ['show', $id, $slug, $season]),3600, $call); // dd($results); $data = $results; // dd($data); // dd($data); $meta['image'] = $data['backdrop']; $meta['schema'] = SchemaBuilder::getShowSchema($results); $meta['title'] = Str::replace(['{TITLE}'], [$data['title']], config('site.shows.detail.title')); $meta['description'] = Str::limit(Str::replace(['{OVERVIEW}'], [$data['overview']], config('site.shows.detail.description')), 150); $meta['keywords'] = config('site.shows.detail.keywords', ''); $is_show_page = true; $show = $data; // dd($season); $season = false; $episode = false; return view('show', compact('show', 'season', 'meta', 'is_show_page', 'airing', 'episode')); } public function season(TmdbClient $tmdb, ApiClient $api, int $id, string $slug = null, int $season = null ) { $airing = []; $is_show_page = is_null($season); $call = function() use($tmdb, $id, &$season, &$airing){ $id = self::decodeId($id); $show = $tmdb->getShow($id); if (isset($season)) { $season_number = (int)$season; // dd($movie); $season = $tmdb->getSeason($show['id'], $season_number); $season = $this->formatTmdbSeason($season, $show); } // $airing = $this->formatTmdbResponse($tmdb->getAiringShows(1), false, [], 12)['data']; return $show; }; $results = $call(); // Cache::remember(implode('__', ['show', $id, $slug, $season]),3600, $call); // dd($results); $data = $results; // dd($data); // dd($data); $meta['image'] = $data['backdrop']; $show = $data; $episode = false; $meta['schema'] = SchemaBuilder::getShowSeasonSchema($results, $season); $meta['title'] = Str::replace(['{TITLE}', '{SEASON}', '{SEASON_TITLE}'], [$data['title'], $season['season_number'], $season['name']], config('site.shows.detail_season.title')); $meta['description'] = Str::limit(Str::replace(['{OVERVIEW}', '{SEASON}'], [ !empty($season['overview']) ? $season['overview'] : sprintf('Season %s - ', $season['season_number']) . $data['overview'], $season['season_number']], config('site.shows.detail_season.description')), 150); $meta['keywords'] = config('site.shows.detail_season.keywords'); // dd($season); return view('show', compact('show', 'season', 'meta', 'is_show_page', 'airing', 'episode')); } public function episode(TmdbClient $tmdb, ApiClient $api, AdsController $adsController, int $id, string $slug, int $season, int $episode) { $similar = []; $season_number = $season; $episode_number = $episode; $call = function() use($tmdb, $id, &$season, &$episode, &$similar, $season_number, $episode_number){ $id = self::decodeId($id); $data = $tmdb->getShow($id); $season = $tmdb->getSeason($data['id'], $season_number); $season = $this->formatTmdbSeason($season, $data); $episode = $tmdb->getEpisode($data['id'], $season_number, $episode_number); $episode = $this->formatTmdbEpisode($episode); return $data; }; $show = $call(); // Cache::remember(implode('__', ['show', $id, $slug, $season]),3600, $call); // dd($results); $meta['schema'] = SchemaBuilder::getShowEpisodeSchema($show, $season, $episode); // load episode background path if available $show['backdrop_path'] = $episode['still_path'] ?? $show['backdrop_path']; $meta['title'] = Str::replace(['{TITLE}', '{SEASON}', '{EPISODE}', '{EPISODE_TITLE}'], [$show['title'], $season_number, $episode_number, $episode['name']], config('site.shows.detail_episode.title')); $meta['description'] = Str::limit(Str::replace(['{OVERVIEW}', '{SEASON}', '{EPISODE}'], [$episode['overview'], $season_number, $episode_number], config('site.shows.detail_episode.description')), 150); $meta['image'] = $episode['backdrop']; $meta['keywords'] = config('site.shows.detail_episode.keywords'); $is_show_page = false; return view('show', compact('show', 'season', 'episode', 'meta', 'is_show_page')); } public function shows( ApiClient $api, TmdbClient $tmdb, ?int $page = 1,) { $results = $this->formatApiResponse($api->getPopularShows($page, 36), true, ['name' => Route::current()->getName()]); $meta['title'] = config('site.shows.list.title', 'Popular Shows'); if ($page > 1) $meta['title'] .= sprintf(' - Page %s', $page); $meta['page_title'] = config('site.shows.list.page_title', 'Popular Shows'); $meta['description'] = config('site.shows.list.description', 'Popular Shows'); $meta['keywords'] = config('site.shows.list.keywords', false); $meta['image'] = asset('images/cover.jpg'); $meta['type'] = 'TV Shows'; $meta['route'] = Route::current(); $pagination = $results['pagination']; $data = $results['data']; $type = 'show'; $genre = false; return view('list', compact('data', 'pagination', 'meta', 'type', 'genre')); } public function shows_more( ApiClient $api, TmdbClient $tmdb, MoreMoviesRequest $moreMoviesRequest) { $results = $this->formatApiResponse($api->getPopularShows($moreMoviesRequest->validated()['page'], 36), true); $items = MoreTitles::collection($results['data']); $has_more_pages = $results['pagination']->hasMorePages(); $current_page = $results['pagination']->currentPage(); $html = LaravelHtmlMinifyFacade::htmlMinify(view('components.more_titles', compact('items'))->render()); return response()->json(compact('current_page', 'has_more_pages', 'html')); } public function genres( ApiClient $api, TmdbClient $tmdb, string $genre, ?int $page = 1) { $genre = Helpers::getShowGenreBySlug($genre); if (is_null($genre)) abort(404); $results = $this->formatApiResponse($api->getGenreShows($genre->id, $page, 36), true, ['name' => Route::current()->getName(), 'params' => ['genre' => $genre->slug]]); $meta['title'] = sprintf(config('site.shows.genres.title', 'Genre Shows'), $genre->name); if ($page > 1) $meta['title'] .= sprintf(' - Page %s', $page); $meta['page_title'] = sprintf(config('site.shows.genres.title', 'Genre Shows'), $genre->name); $meta['description'] = sprintf(config('site.shows.genres.description', 'Genre Shows'), $genre->name); $meta['keywords'] = config('site.shows.genres.keywords'); $meta['image'] = asset('images/cover.jpg'); $meta['route'] = Route::current(); $pagination = $results['pagination']; // dd($pagination); $data = $results['data']; $type = 'show'; return view('list', compact('data', 'pagination', 'meta', 'genre', 'type')); } }