feat: adds ability for approved users to approve artwork
This commit is contained in:
@@ -37,9 +37,7 @@ class ArtworkController extends Controller
|
||||
->orderBy('episode_number', 'desc')
|
||||
->orderBy('artworks.created_at', 'desc')
|
||||
->paginate($perPage = 52, $columns = ['*'], $pageName = 'artworks');
|
||||
$podcasts = Cache::remember('publishedPodcasts', 30, function() {
|
||||
return Podcast::where('published', true)->get();
|
||||
});
|
||||
$podcasts = $this->publishedPodcasts();
|
||||
return view('explore.artworks', [
|
||||
'user' => $user,
|
||||
'pageTitle' => 'Explore',
|
||||
@@ -56,9 +54,7 @@ class ArtworkController extends Controller
|
||||
public function create()
|
||||
{
|
||||
$user = auth()->user();
|
||||
$podcasts = Cache::remember('publishedPodcasts', 30, function() {
|
||||
return Podcast::where('published', true)->get();
|
||||
});
|
||||
$podcasts = $this->publishedPodcasts();
|
||||
return view('artworks.submit', [
|
||||
'user' => $user,
|
||||
'pageTitle' => 'Submit New Artwork',
|
||||
@@ -66,6 +62,41 @@ class ArtworkController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
public function pendingApproval(Request $request)
|
||||
{
|
||||
$user = auth()->user();
|
||||
if ($request->user()->cannot('approve', Artwork::class)) {
|
||||
abort(403);
|
||||
}
|
||||
$artworks = Artwork::whereNull('approved_by')
|
||||
->orderBy('created_at', 'desc')
|
||||
->paginate(50);
|
||||
$podcasts = $this->publishedPodcasts();
|
||||
return view('artworks.approvals', [
|
||||
'user' => $user,
|
||||
'pageTitle' => 'Approve Artworks',
|
||||
'podcasts' => $podcasts,
|
||||
'artworks' => $artworks,
|
||||
]);
|
||||
}
|
||||
|
||||
public function approve(Request $request)
|
||||
{
|
||||
$user = $request->user();
|
||||
if ($request->user()->cannot('approve', Artwork::class)) {
|
||||
abort(403);
|
||||
}
|
||||
$validated = $request->validate([
|
||||
'artwork_id' => 'required|exists:artworks,id'
|
||||
]);
|
||||
$artwork = Artwork::find($request->artwork_id);
|
||||
if (is_null($artwork->approved_by)) {
|
||||
$artwork->approved_by = $user->artists->first()->id;
|
||||
$artwork->save();
|
||||
}
|
||||
return redirect('/approve-artworks');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
@@ -108,7 +139,7 @@ class ArtworkController extends Controller
|
||||
'description' => $request->description,
|
||||
'overlay_id' => null,
|
||||
'podcast_id' => $podcast->id,
|
||||
'episode_id' => $episode->id,
|
||||
'episode_id' => $episode->id,
|
||||
//'approved_by' => 4,
|
||||
'filename' => $filename,
|
||||
'created_at' => now(),
|
||||
@@ -190,16 +221,6 @@ class ArtworkController extends Controller
|
||||
//
|
||||
}
|
||||
|
||||
public function approve(Artwork $artwork)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$awatingApproval = Artwork::whereNull('approved_by')
|
||||
->with('podcast')
|
||||
->with('podcast.episode')
|
||||
->orderBy('created_at', 'asc')
|
||||
->get();
|
||||
}
|
||||
|
||||
public function legacyArtLink(Request $request, $any = null)
|
||||
{
|
||||
phpinfo();
|
||||
@@ -228,4 +249,11 @@ class ArtworkController extends Controller
|
||||
->header('Content-Disposition', 'attachment; filename="naartgen-archivelist-' . $type . '.txt"');
|
||||
}
|
||||
|
||||
private function publishedPodcasts() {
|
||||
$podcasts = Cache::remember('publishedPodcasts', 30, function() {
|
||||
return Podcast::where('published', true)->get();
|
||||
});
|
||||
return $podcasts;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -55,6 +55,7 @@ class EpisodeController extends Controller
|
||||
->with('artworks')
|
||||
->with('artwork')
|
||||
->with('podcast')
|
||||
->whereNotNull('artworks.approved_by')
|
||||
->firstOrFail();
|
||||
$podcasts = Podcast::where('published', true)->with('episodes', function ($query) {
|
||||
$query->orderBy('episode_number', 'desc');
|
||||
|
||||
Reference in New Issue
Block a user