Adds latest episode api endpoint and some other minor modifications.

This commit is contained in:
2025-07-27 16:44:50 +00:00
parent 97b018f2bc
commit 667f0acd83
30 changed files with 3007 additions and 3336 deletions

View File

@@ -72,6 +72,7 @@ class ArtistController extends Controller
$artworks = Artwork::where('artist_id', $artist->id)
->with('episode')
->with('podcast')
->whereNotNull('approved_by')
->orderBy('artworks.created_at', 'desc')
->paginate($perPage = 92, $columns = ['*'], $pageName = 'artworks');
$podcasts = Podcast::where('published', true)->with('episodes')->get();

View File

@@ -26,7 +26,7 @@ class PasswordResetLinkController extends Controller
public function store(Request $request): RedirectResponse
{
$request->validate([
'email' => ['required', 'email'],
'email' => ['required', 'email', 'exists:users,email'],
]);
// We will send the password reset link to this user. Once we have attempted

View File

@@ -8,6 +8,7 @@ use Illuminate\Support\Facades\DB;
use App\Models\Podcast;
use App\Models\Artworks;
use App\Models\Episode;
use App\Http\Resources\LatestEpisodeResource;
class PodcastController extends Controller
@@ -33,4 +34,26 @@ class PodcastController extends Controller
'podcasts' => $podcasts,
]);
}
/**
* Display the latest episode's chosen artwork for third party tools.
*
* @param $slug
* @return \Illuminate\Http\Response
*/
public function latest_artwork(Request $request, $slug)
{
$podcast = Podcast::with('latestArtwork.artist')
->where('slug', $slug)
->where('published', true)
->firstOrFail();
$art = $podcast->latestArtwork;
return new LatestEpisodeResource($podcast);
return response()->json([
'episode_number' => optional($podcast->latestEpisode)->episode_number,
'artwork' => $art,
'artist' => optional($art)->artist,
]);
}
}