koel/app/Http/Controllers/API/Podcast/PodcastEpisodeController.php

28 lines
715 B
PHP
Raw Normal View History

2024-05-19 05:49:42 +00:00
<?php
namespace App\Http\Controllers\API\Podcast;
use App\Http\Controllers\Controller;
use App\Http\Resources\SongResource;
use App\Models\Podcast\Podcast;
use App\Repositories\SongRepository;
use App\Services\PodcastService;
class PodcastEpisodeController extends Controller
{
public function __construct(
private readonly SongRepository $episodeRepository,
private readonly PodcastService $podcastService
) {
}
public function index(Podcast $podcast)
{
if (request()->get('refresh')) {
$this->podcastService->refreshPodcast($podcast);
}
return SongResource::collection($this->episodeRepository->getEpisodesByPodcast($podcast));
}
}