fix: limit episode art to approved arworks #5

Merged
pcouture merged 1 commits from fix/episode_filter_unapproved into master 2024-01-13 12:32:21 -05:00
3 changed files with 10 additions and 5 deletions
Showing only changes of commit 37d496bbca - Show all commits

View File

@ -52,10 +52,9 @@ public function show(Request $request, $podcast_slug, $slug)
{ {
$user = auth()->user(); $user = auth()->user();
$episode = Episode::where('slug', $slug) $episode = Episode::where('slug', $slug)
->with('artworks') ->with('approvedArtworks')
->with('artwork') ->with('artwork')
->with('podcast') ->with('podcast')
->whereNotNull('artworks.approved_by')
->firstOrFail(); ->firstOrFail();
$podcasts = Podcast::where('published', true)->with('episodes', function ($query) { $podcasts = Podcast::where('published', true)->with('episodes', function ($query) {
$query->orderBy('episode_number', 'desc'); $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), 'pageTitle' => '"' . $episode->title . '" ' . $episode->podcast->name . ' Episode ' . number_format($episode->episode_number + 0),
'podcast' => $episode->podcast, 'podcast' => $episode->podcast,
'episode' => $episode, 'episode' => $episode,
'artworks' => $episode->approvedArtworks,
'podcasts' => $podcasts, 'podcasts' => $podcasts,
]); ]);
} }

View File

@ -31,6 +31,11 @@ public function artwork()
return $this->hasOne(Artwork::class, 'id', 'artwork_id'); return $this->hasOne(Artwork::class, 'id', 'artwork_id');
} }
public function approvedArtworks()
{
return $this->hasMany(Artwork::class)->whereNotNull('artworks.approved_by');
}
public function artworks() public function artworks()
{ {
return $this->hasMany(Artwork::class); return $this->hasMany(Artwork::class);

View File

@ -44,7 +44,7 @@
{{ $episode->episode_date->format('Y') }}</h4> {{ $episode->episode_date->format('Y') }}</h4>
<h4 class="mb-4">Artwork By: <a href="/artist/{{ $episode->artwork->artist->slug }}">{{ $episode->artwork->artist->name }}</a></h4> <h4 class="mb-4">Artwork By: <a href="/artist/{{ $episode->artwork->artist->slug }}">{{ $episode->artwork->artist->name }}</a></h4>
<p class="subtitle"> <p class="subtitle">
{{ number_format($episode->artworks->count()) }} Artworks Submitted. {{ number_format($artworks->count()) }} Artworks Submitted.
</p> </p>
<div class="container"> <div class="container">
<div class="row"> <div class="row">
@ -88,14 +88,14 @@ class="ri-broadcast-line"></i>
<div class="container"> <div class="container">
<div class="section-title"> <div class="section-title">
<span class="subtitle">Other Submitted Artworks</span> <span class="subtitle">Other Submitted Artworks</span>
<h3>{{ number_format($episode->artworks->count() - 1) }} other art pieces submitted</h3> <h3>{{ number_format($artworks->count() - 1) }} other art pieces submitted</h3>
</div> </div>
</div> </div>
<div class="container"> <div class="container">
{{-- End .section-title --}} {{-- End .section-title --}}
<div class="grid-filter-wrapper masonry-list"> <div class="grid-filter-wrapper masonry-list">
<div class="resizer"></div> <div class="resizer"></div>
@foreach ($episode->artworks as $recent) @foreach ($artworks as $recent)
@if ($recent->id != $episode->artwork_id) @if ($recent->id != $episode->artwork_id)
@php @php
$thisArtwork = $recent; $thisArtwork = $recent;