From 37d496bbcaebd7b8e52bbf084aa552adf2ef2262 Mon Sep 17 00:00:00 2001 From: Paul Couture Date: Sat, 13 Jan 2024 11:30:38 -0600 Subject: [PATCH] fix: limit episode art to approved arworks --- site/app/Http/Controllers/EpisodeController.php | 4 ++-- site/app/Models/Episode.php | 5 +++++ site/resources/views/episodes/episode.blade.php | 6 +++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/site/app/Http/Controllers/EpisodeController.php b/site/app/Http/Controllers/EpisodeController.php index fbb622d..903e0b4 100644 --- a/site/app/Http/Controllers/EpisodeController.php +++ b/site/app/Http/Controllers/EpisodeController.php @@ -52,10 +52,9 @@ public function show(Request $request, $podcast_slug, $slug) { $user = auth()->user(); $episode = Episode::where('slug', $slug) - ->with('artworks') + ->with('approvedArtworks') ->with('artwork') ->with('podcast') - ->whereNotNull('artworks.approved_by') ->firstOrFail(); $podcasts = Podcast::where('published', true)->with('episodes', function ($query) { $query->orderBy('episode_number', 'desc'); @@ -67,6 +66,7 @@ public function show(Request $request, $podcast_slug, $slug) 'pageTitle' => '"' . $episode->title . '" ' . $episode->podcast->name . ' Episode ' . number_format($episode->episode_number + 0), 'podcast' => $episode->podcast, 'episode' => $episode, + 'artworks' => $episode->approvedArtworks, 'podcasts' => $podcasts, ]); } diff --git a/site/app/Models/Episode.php b/site/app/Models/Episode.php index b0f4659..c2d2b2d 100644 --- a/site/app/Models/Episode.php +++ b/site/app/Models/Episode.php @@ -31,6 +31,11 @@ public function artwork() return $this->hasOne(Artwork::class, 'id', 'artwork_id'); } + public function approvedArtworks() + { + return $this->hasMany(Artwork::class)->whereNotNull('artworks.approved_by'); + } + public function artworks() { return $this->hasMany(Artwork::class); diff --git a/site/resources/views/episodes/episode.blade.php b/site/resources/views/episodes/episode.blade.php index 6d862e5..d68e377 100644 --- a/site/resources/views/episodes/episode.blade.php +++ b/site/resources/views/episodes/episode.blade.php @@ -44,7 +44,7 @@ {{ $episode->episode_date->format('Y') }}

Artwork By: {{ $episode->artwork->artist->name }}

- {{ number_format($episode->artworks->count()) }} Artworks Submitted. + {{ number_format($artworks->count()) }} Artworks Submitted.

@@ -88,14 +88,14 @@ class="ri-broadcast-line">
Other Submitted Artworks -

{{ number_format($episode->artworks->count() - 1) }} other art pieces submitted

+

{{ number_format($artworks->count() - 1) }} other art pieces submitted

{{-- End .section-title --}}
- @foreach ($episode->artworks as $recent) + @foreach ($artworks as $recent) @if ($recent->id != $episode->artwork_id) @php $thisArtwork = $recent; -- 2.45.2