Adds latest episode api endpoint and some other minor modifications.
This commit is contained in:
@@ -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,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user