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

@@ -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,
]);
}
}