feat: presents popular tv shows on landing page
This commit is contained in:
@@ -22,6 +22,7 @@ final class IndexController extends AbstractController
|
||||
'active_downloads' => $this->downloadRepository->getActivePaginated(),
|
||||
'recent_downloads' => $this->downloadRepository->latest(5),
|
||||
'popular_movies' => $this->tmdb->popularMovies(1, 6),
|
||||
'popular_tvshows' => $this->tmdb->popularTvShows(1, 6),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,6 +111,23 @@ class Tmdb
|
||||
return $movies;
|
||||
}
|
||||
|
||||
public function popularTvShows(int $page = 1, ?int $limit = null)
|
||||
{
|
||||
$movies = $this->tvRepository->getPopular(['page' => $page]);
|
||||
|
||||
$movies = $movies->map(function ($movie) use ($movies) {
|
||||
return $this->parseResult($movies[$movie], "movie");
|
||||
});
|
||||
|
||||
$movies = array_values($movies->toArray());
|
||||
|
||||
if (null !== $limit) {
|
||||
$movies = array_slice($movies, 0, $limit);
|
||||
}
|
||||
|
||||
return $movies;
|
||||
}
|
||||
|
||||
public function search(string $term, int $page = 1)
|
||||
{
|
||||
$searchRepository = new SearchRepository($this->client);
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
<div{{ attributes }}>
|
||||
<a href="{{ path('app_search_result', {
|
||||
mediaType: "movies",
|
||||
mediaType: mediaType,
|
||||
tmdbId: tmdbId
|
||||
}) }}">
|
||||
<img src="{{ image }}" class="w-40 rounded-md" />
|
||||
</a>
|
||||
<a href="{{ path('app_search_result', {
|
||||
mediaType: "movies",
|
||||
mediaType: mediaType,
|
||||
tmdbId: tmdbId
|
||||
}) }}">
|
||||
<h3 class="text-center text-gray-50 max-w-[16ch] text-extrabold">{{ title }}</h3>
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
</table>
|
||||
</twig:Card>
|
||||
</div>
|
||||
<div class="">
|
||||
<div class="flex flex-col gap-4">
|
||||
<twig:Card title="Popular Movies" contentClass="flex flex-row justify-between w-full">
|
||||
{% for movie in popular_movies %}
|
||||
<twig:Poster imdbId=""
|
||||
@@ -62,7 +62,21 @@
|
||||
title="{{ movie.title }}"
|
||||
description="{{ movie.description }}"
|
||||
image="{{ movie.poster }}"
|
||||
year="{{ movie.year }}" />
|
||||
year="{{ movie.year }}"
|
||||
mediaType="movies"
|
||||
/>
|
||||
{% endfor %}
|
||||
</twig:Card>
|
||||
<twig:Card title="Popular TV Shows" contentClass="flex flex-row justify-between w-full">
|
||||
{% for movie in popular_tvshows %}
|
||||
<twig:Poster imdbId=""
|
||||
tmdbId="{{ movie.tmdbId }}"
|
||||
title="{{ movie.title }}"
|
||||
description="{{ movie.description }}"
|
||||
image="{{ movie.poster }}"
|
||||
year="{{ movie.year }}"
|
||||
mediaType="tvshows"
|
||||
/>
|
||||
{% endfor %}
|
||||
</twig:Card>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user