getShow($id); $data = $this->formatTmdbShow($show); $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 = false; $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, int $season = null, string $slug = null ) { $airing = []; $is_show_page = is_null($season); $call = function() use($tmdb, $id, &$season, &$airing){ $id = self::decodeId($id); $show = $tmdb->getShow($id); $data = $this->formatTmdbShow($show); 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']; // dd($data); // $data['meta']['title'] = 'Watch ' . $movie['title']; 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']; $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, int $season, int $episode, string $slug) { $similar = []; $season_number = $season; $episode_number = $episode; $call = function() use($tmdb, $id, &$season, &$episode, &$similar, $season_number, $episode_number){ $id = self::decodeId($id); $show = $tmdb->getShow($id); $data = $this->formatTmdbShow($show); $season = $tmdb->getSeason($show['id'], $season_number); $season = $this->formatTmdbSeason($season); $episode = $tmdb->getEpisode($show['id'], $season_number, $episode_number); $episode = $this->formatTmdbEpisode($episode); // $episode // dd($data); // $data['meta']['title'] = 'Watch ' . $movie['title']; return $data; }; $results = $call(); // Cache::remember(implode('__', ['show', $id, $slug, $season]),3600, $call); // dd($results); $meta['schema'] = SchemaBuilder::getShowEpisodeSchema($results, $season, $episode); $data = $results; $top = $this->getTopContent($tmdb, $api); // dd($data); // dd($upcoming); $meta['title'] = Str::replace(['{TITLE}', '{SEASON}', '{EPISODE}', '{EPISODE_TITLE}'], [$data['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'); // dd($season); if (defined('SHOULD_PRERENDER')) { return view('prerender.show', compact('data', 'season', 'episode', 'meta', 'top')); } $modal = $adsController->shouldGetModal(request()->headers->get('cf-ipcountry', 'AU')); $meta = self::encodeForInertia($meta ?? []) ; $top = self::encodeForInertia($top); $data = self::encodeForInertia($data ?? []); $season = self::encodeForInertia($season ?? []); $episode = self::encodeForInertia($episode ?? []); return Inertia::render('Show', compact('data', 'season', 'episode', 'meta', 'top', 'modal')); } 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.title', 'Popular Shows'); $meta['description'] = config('site.shows.list.description', 'Popular Shows'); $meta['keywords'] = config('site.shows.list.keywords', false); $meta['image'] = asset('images/custom-icon.png'); $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/custom-icon.png'); $meta['route'] = Route::current(); $pagination = $results['pagination']; // dd($pagination); $data = $results['data']; $type = 'show'; return view('list', compact('data', 'pagination', 'meta', 'genre', 'type')); } }