Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Fix) Don't use hardcoded category ids in random media #4087

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/Http/Livewire/RandomMedia.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ final public function movies(): \Illuminate\Support\Collection

return Movie::query()
->select(['id', 'backdrop', 'title', 'release_date'])
->withMin('torrents', 'category_id')
->whereIn('id', $movieIds)
->get();
}
Expand All @@ -52,6 +53,7 @@ final public function movies2(): \Illuminate\Support\Collection

return Movie::query()
->select(['id', 'backdrop', 'title', 'release_date'])
->withMin('torrents', 'category_id')
->whereIn('id', $movieIds)
->get();
}
Expand All @@ -68,6 +70,7 @@ final public function tvs(): \Illuminate\Support\Collection

return Tv::query()
->select(['id', 'backdrop', 'name', 'first_air_date'])
->withMin('torrents', 'category_id')
->whereIn('id', $tvIds)
->get();
}
Expand Down
12 changes: 6 additions & 6 deletions resources/views/livewire/random-media.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
@foreach ($movies as $key => $movie)
<a
target="_blank"
href="{{ route('torrents.similar', ['category_id' => 1, 'tmdb' => $movie->id]) }}"
href="{{ route('torrents.similar', ['category_id' => $movie->torrents_min_category_id ?? 1, 'tmdb' => $movie->id]) }}"
class="@if ($loop->iteration == 1) media @elseif ($loop->iteration == 2)media1 @else media2 @endif"
style="
background-image: url('{{ \tmdb_image('back_small', $movie->backdrop) }}');
Expand All @@ -29,15 +29,15 @@ class="@if ($loop->iteration == 1) media @elseif ($loop->iteration == 2)media1 @
>
<span style="padding-left: 6px">MOVIE</span>
<div class="media__title">
{{ $movie->title }} ({{ substr($movie->release_date ?? '', 0, 4) ?? '' }})
{{ $movie->title }} ({{ $movie->release_date?->format('Y') }})
</div>
</a>
@endforeach

@foreach ($tvs as $key => $tv)
<a
target="_blank"
href="{{ route('torrents.similar', ['category_id' => 2, 'tmdb' => $tv->id]) }}"
href="{{ route('torrents.similar', ['category_id' => $tv->torrents_min_category_id ?? 2, 'tmdb' => $tv->id]) }}"
class="@if ($loop->iteration == 1) media3 @elseif ($loop->iteration == 2) media4 @else media5 @endif"
style="
background-image: url('{{ \tmdb_image('back_small', $tv->backdrop) }}');
Expand All @@ -48,15 +48,15 @@ class="@if ($loop->iteration == 1) media3 @elseif ($loop->iteration == 2) media4
>
<span style="padding-left: 6px">TV</span>
<div class="media__title">
{{ $tv->name }} ({{ substr($tv->first_air_date ?? '', 0, 4) ?? '' }})
{{ $tv->name }} ({{ $tv->first_air_date?->format('Y') }})
</div>
</a>
@endforeach

@foreach ($movies2 as $key => $movie)
<a
target="_blank"
href="{{ route('torrents.similar', ['category_id' => 1, 'tmdb' => $movie->id]) }}"
href="{{ route('torrents.similar', ['category_id' => $movie->torrents_min_category_id ?? 1, 'tmdb' => $movie->id]) }}"
class="@if ($loop->iteration == 1) media6 @elseif ($loop->iteration == 2) media7 @else media8 @endif"
style="
background-image: url('{{ \tmdb_image('back_small', $movie->backdrop) }}');
Expand All @@ -67,7 +67,7 @@ class="@if ($loop->iteration == 1) media6 @elseif ($loop->iteration == 2) media7
>
<span style="padding-left: 6px">MOVIE</span>
<div class="media__title">
{{ $movie->title }} ({{ substr($movie->release_date ?? '', 0, 4) ?? '' }})
{{ $movie->title }} ({{ $movie->release_date?->format('Y') }})
</div>
</a>
@endforeach
Expand Down
Loading