mirror of
https://github.com/ceratic/MediaCollectorLibary.git
synced 2026-05-13 23:56:46 +02:00
dont know ?
This commit is contained in:
@@ -109,7 +109,7 @@ class TvShowController extends Controller
|
||||
$cast = json_decode($tvShow['cast'] ?? '[]', true);
|
||||
$genre = json_decode($tvShow['genre'] ?? '[]', true);
|
||||
|
||||
// Get actors for this TV show
|
||||
// Get actors for this TV show (from main cast)
|
||||
$stmt = $this->pdo->prepare("
|
||||
SELECT a.*
|
||||
FROM actors a
|
||||
@@ -118,10 +118,59 @@ class TvShowController extends Controller
|
||||
ORDER BY a.name ASC
|
||||
");
|
||||
$stmt->execute(['tv_show_id' => $tvShowId]);
|
||||
$actors = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||
$mainActors = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||
|
||||
// Get all actors from episodes
|
||||
$stmt = $this->pdo->prepare("
|
||||
SELECT DISTINCT a.*
|
||||
FROM actors a
|
||||
JOIN actor_tv_episode ate ON a.id = ate.actor_id
|
||||
JOIN tv_episodes e ON ate.tv_episode_id = e.id
|
||||
WHERE e.tv_show_id = :tv_show_id
|
||||
ORDER BY a.name ASC
|
||||
");
|
||||
$stmt->execute(['tv_show_id' => $tvShowId]);
|
||||
$episodeActors = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||
|
||||
// Merge and deduplicate actors
|
||||
$allActors = array_merge($mainActors, $episodeActors);
|
||||
$actorsById = [];
|
||||
foreach ($allActors as $actor) {
|
||||
$actorsById[$actor['id']] = $actor;
|
||||
}
|
||||
$actors = array_values($actorsById);
|
||||
// Sort by name
|
||||
usort($actors, function($a, $b) {
|
||||
return strcmp($a['name'], $b['name']);
|
||||
});
|
||||
// Get seasons and episodes for this TV show
|
||||
$tvShowModel = new TvShow($this->pdo, $tvShow);
|
||||
$seasons = $tvShowModel->getSeasonsWithEpisodes();
|
||||
|
||||
// Get recent episodes (last 5 aired episodes)
|
||||
$stmt = $this->pdo->prepare("
|
||||
SELECT e.*
|
||||
FROM tv_episodes e
|
||||
WHERE e.tv_show_id = :tv_show_id AND e.air_date IS NOT NULL
|
||||
ORDER BY e.air_date DESC
|
||||
LIMIT 5
|
||||
");
|
||||
$stmt->execute(['tv_show_id' => $tvShowId]);
|
||||
$recent_episodes = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||
|
||||
// Add actors for recent episodes
|
||||
foreach ($recent_episodes as &$episode) {
|
||||
$episodeStmt = $this->pdo->prepare("
|
||||
SELECT a.*
|
||||
FROM actors a
|
||||
JOIN actor_tv_episode ate ON a.id = ate.actor_id
|
||||
WHERE ate.tv_episode_id = :tv_episode_id
|
||||
ORDER BY a.name ASC
|
||||
");
|
||||
$episodeStmt->execute(['tv_episode_id' => $episode['id']]);
|
||||
$episode['actors'] = $episodeStmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||
}
|
||||
|
||||
return $this->view->render($response, 'tvshows/show.twig', [
|
||||
'title' => $tvShow['title'],
|
||||
'tvshow' => $tvShow,
|
||||
@@ -129,7 +178,8 @@ class TvShowController extends Controller
|
||||
'cast' => $cast,
|
||||
'genre' => $genre,
|
||||
'actors' => $actors,
|
||||
'seasons' => $seasons
|
||||
'seasons' => $seasons,
|
||||
'recent_episodes' => $recent_episodes
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user