Skip to content

Commit f616a1f

Browse files
committed
update: collection on similar meta and collection posters
Show all movies in a collection that the current movie is in, in the similar meta. Also show movie posters instead of a collection card in the relations panel on the torrent page. Reorganize the relations so that plurals are correct and match the relation stored in the database. Even though there can be only one collection per movie as defined by tmdb, that's not the way the tables are stored and the queries are done, so use plural naming for now.
1 parent 9226538 commit f616a1f

File tree

14 files changed

+120
-40
lines changed

14 files changed

+120
-40
lines changed

app/Http/Controllers/MediaHub/TmdbCollectionController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function index(): \Illuminate\Contracts\View\Factory|\Illuminate\View\Vie
3535
public function show(int $id): \Illuminate\Contracts\View\Factory|\Illuminate\View\View
3636
{
3737
return view('mediahub.collection.show', [
38-
'collection' => TmdbCollection::with(['movie' => fn ($query) => $query->has('torrents'), 'comments'])->findOrFail($id),
38+
'collection' => TmdbCollection::with(['movies' => fn ($query) => $query->has('torrents'), 'comments'])->findOrFail($id),
3939
]);
4040
}
4141
}

app/Http/Controllers/RequestController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function show(Request $request, TorrentRequest $torrentRequest): \Illumin
7878
'genres',
7979
'credits' => ['person', 'occupation'],
8080
'companies',
81-
'collection'
81+
'collections.movies'
8282
])
8383
->find($torrentRequest->tmdb_movie_id),
8484
($torrentRequest->category->game_meta && $torrentRequest->igdb) => IgdbGame::with([

app/Http/Controllers/SimilarTorrentController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ public function show(int $categoryId, int $tmdbId): \Illuminate\Contracts\View\F
4545
$meta = TmdbMovie::with([
4646
'genres',
4747
'credits' => ['person', 'occupation'],
48-
'companies'
48+
'companies',
49+
'collections.movies',
4950
])
5051
->findOrFail($tmdbId);
5152
$tmdb = $tmdbId;

app/Http/Controllers/TorrentController.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,10 @@ public function show(Request $request, int|string $id): \Illuminate\Contracts\Vi
119119
'genres',
120120
'credits' => ['person', 'occupation'],
121121
'companies',
122-
'collection',
122+
'collections.movies' => fn ($query) => $query
123+
->select('tmdb_movies.id', 'tmdb_movies.title', 'tmdb_movies.poster', 'tmdb_movies.release_date')
124+
->withMin('torrents', 'category_id')
125+
->has('torrents'),
123126
'recommendedMovies' => fn ($query) => $query
124127
->select('tmdb_movies.id', 'tmdb_movies.title', 'tmdb_movies.poster', 'tmdb_movies.release_date')
125128
->withMin('torrents', 'category_id')

app/Http/Livewire/TmdbCollectionSearch.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ final public function updatingSearch(): void
4242
#[Computed]
4343
final public function collections(): \Illuminate\Pagination\LengthAwarePaginator
4444
{
45-
return TmdbCollection::withCount('movie')
46-
->with('movie')
45+
return TmdbCollection::withCount('movies')
46+
->with('movies')
4747
->when($this->search !== '', fn ($query) => $query->where('name', 'LIKE', '%'.$this->search.'%'))
4848
->oldest('name')
4949
->paginate(25);

app/Models/TmdbCollection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function comments(): \Illuminate\Database\Eloquent\Relations\MorphMany
5252
/**
5353
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany<TmdbMovie, $this>
5454
*/
55-
public function movie(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
55+
public function movies(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
5656
{
5757
return $this->belongsToMany(TmdbMovie::class);
5858
}

app/Models/TmdbMovie.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,9 @@ public function companies(): \Illuminate\Database\Eloquent\Relations\BelongsToMa
111111
/**
112112
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany<TmdbCollection, $this>
113113
*/
114-
public function collection(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
114+
public function collections(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
115115
{
116-
return $this->belongsToMany(TmdbCollection::class)->take(1);
116+
return $this->belongsToMany(TmdbCollection::class);
117117
}
118118

119119
/**

resources/sass/components/_meta.scss

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,15 @@
318318
will-change: backdrop-filter, background;
319319
}
320320

321+
.meta-chip--value-only {
322+
grid-template-areas: 'image value';
323+
324+
.meta-chip__value {
325+
height: auto;
326+
align-self: center;
327+
}
328+
}
329+
321330
.meta-chip:hover {
322331
backdrop-filter: var(--meta-chip-backdrop-filter-hover);
323332
-webkit-backdrop-filter: var(--meta-chip-backdrop-filter-hover);
@@ -391,6 +400,13 @@
391400
color: var(--meta-chip-value-hover-fg);
392401
}
393402

403+
.meta-chip__list {
404+
display: flex;
405+
margin-left: 8px;
406+
flex-direction: column;
407+
column-gap: 12px;
408+
}
409+
394410
@media screen and (max-width: 767px) {
395411
.meta-chip {
396412
display: flex;

resources/sass/pages/_torrent.scss

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,17 @@
9696
overflow-x: auto;
9797
}
9898

99+
/* Collection
100+
---------------------------------------------------------------------------- */
101+
102+
.collection-posters {
103+
display: grid;
104+
grid-auto-columns: 150px;
105+
grid-auto-flow: column;
106+
gap: 12px 24px;
107+
overflow-x: auto;
108+
}
109+
99110
/* NFO
100111
---------------------------------------------------------------------------- */
101112

resources/views/blocks/featured.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class="featured-carousel"
5757
->with('genres', 'networks', 'seasons')
5858
->find($feature->torrent->tmdb_tv_id ?? 0),
5959
$feature->torrent->category->movie_meta => App\Models\TmdbMovie::query()
60-
->with('genres', 'companies', 'collection')
60+
->with('genres', 'companies')
6161
->find($feature->torrent->tmdb_movie_id ?? 0),
6262
$feature->torrent->category->game_meta => App\Models\Game::query()
6363
->with('genres')

resources/views/livewire/tmdb-collection-search.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class="collection__link"
4444
</h3>
4545
<p class="collection__description">
4646
{{ __('mediahub.includes') }}
47-
{{ $collection->movie->pluck('title')->implode(',') }}
47+
{{ $collection->movies->pluck('title')->implode(',') }}
4848
</p>
4949
</article>
5050
</li>

resources/views/mediahub/collection/show.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class="form__button form__button--text"
6868
</div>
6969
</header>
7070
<div class="panel__body torrent-search--poster__results">
71-
@foreach ($collection->movie->sortBy('release_date') as $movie)
71+
@foreach ($collection->movies->sortBy('release_date') as $movie)
7272
<x-movie.poster
7373
:movie="$movie"
7474
:category-id="$movie->torrents()->first()->category_id"
Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,9 @@
1-
<div class="panel__body" style="padding: 5px">
2-
@if (! empty($meta->collection['0']) && $torrent->category->movie_meta)
3-
<article
4-
class="collection"
5-
style="
6-
background-image: linear-gradient(rgba(0, 0, 0, 0.87), rgba(45, 71, 131, 0.46)),
7-
url({{ isset($meta->collection['0']->backdrop) ? tmdb_image('back_big', $meta->collection['0']->backdrop) : 'https://via.placeholder.com/1280x300' }});
8-
"
9-
>
10-
<h3 class="collection__heading">
11-
<a
12-
class="collection__link"
13-
href="{{ route('mediahub.collections.show', ['id' => $meta->collection['0']->id]) }}"
14-
>
15-
{{ $meta->collection['0']->name }}
16-
</a>
17-
</h3>
18-
<p class="collection__description">
19-
{{ __('mediahub.includes') }}
20-
{{ $meta->collection['0']->movie->pluck('title')->implode(',') }}
21-
</p>
22-
</article>
1+
<div class="panel__body collection-posters" style="padding: 5px">
2+
@if ($meta?->collections->isNotEmpty() && $torrent->category->movie_meta)
3+
@foreach ($meta?->collections?->first()?->movies as $movie)
4+
<x-movie.poster :$movie :categoryId="$movie->torrents_min_category_id" />
5+
@endforeach
236
@else
24-
<div class="text-center">
25-
<h4 class="text-bold text-danger">
26-
<i class="{{ config('other.font-awesome') }} fa-frown"></i>
27-
No Collection Found!
28-
</h4>
29-
</div>
7+
No Collection Found!
308
@endif
319
</div>

resources/views/torrent/partials/movie_meta.blade.php

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,77 @@ class="meta-chip"
299299
</h3>
300300
</a>
301301
</article>
302+
303+
@if ($meta?->collections?->isNotEmpty())
304+
<article class="meta__collection">
305+
<details>
306+
<summary class="meta-chip">
307+
<i
308+
class="{{ config('other.font-awesome') }} fa-rectangle-history meta-chip__icon"
309+
></i>
310+
<h2 class="meta-chip__name">Collection</h2>
311+
<h3 class="meta-chip__value">
312+
{{ $meta?->collections?->first()?->name }}
313+
</h3>
314+
</summary>
315+
<div class="meta-chip__list">
316+
<article class="meta__collection-item">
317+
<a
318+
class="meta-chip meta-chip--value-only"
319+
href="{{ route('mediahub.collections.show', ['id' => $meta?->collections?->first()?->id]) }}"
320+
>
321+
@if ($meta?->collections?->first()->poster)
322+
<img
323+
class="meta-chip__image"
324+
src="{{ tmdb_image('poster_small', $meta?->collections?->first()->poster) }}"
325+
alt=""
326+
/>
327+
@else
328+
<i
329+
class="{{ config('other.font-awesome') }} fa-rectangle-history meta-chip__icon"
330+
></i>
331+
@endif
332+
<h3 class="meta-chip__value">View all</h3>
333+
</a>
334+
</article>
335+
@foreach ($meta?->collections?->first()->movies as $movie)
336+
<article class="meta__collection-item">
337+
<a
338+
class="meta-chip meta-chip--value-only"
339+
href="{{ route('torrents.similar', ['tmdb' => $movie->id, 'category_id' => $category->id]) }}"
340+
>
341+
@if ($movie->poster)
342+
<img
343+
class="meta-chip__image"
344+
src="{{ tmdb_image('poster_small', $movie->poster) }}"
345+
alt=""
346+
/>
347+
@else
348+
<i
349+
class="{{ config('other.font-awesome') }} fa-film meta-chip__icon"
350+
></i>
351+
@endif
352+
@if ($movie->is($meta))
353+
<h3 class="meta-chip__value">
354+
<strong>
355+
{{ $movie->title }}
356+
({{ $movie->release_date->format('Y') }})
357+
</strong>
358+
</h3>
359+
@else
360+
<h3 class="meta-chip__value">
361+
{{ $movie->title }}
362+
({{ $movie->release_date->format('Y') }})
363+
</h3>
364+
@endif
365+
</a>
366+
</article>
367+
@endforeach
368+
</div>
369+
</details>
370+
</article>
371+
@endif
372+
302373
@foreach ($meta?->companies ?? [] as $company)
303374
<article class="meta__company">
304375
<a

0 commit comments

Comments
 (0)