Skip to content
Snippets Groups Projects
PodcastPersonController.php 2.32 KiB
Newer Older
  • Learn to ignore specific revisions
  •  * @copyright  2020 Ad Aures
    
     * @license    https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
     * @link       https://castopod.org/
     */
    
    
    use App\Models\PersonModel;
    
    use App\Models\PodcastModel;
    use CodeIgniter\Exceptions\PageNotFoundException;
    use CodeIgniter\HTTP\RedirectResponse;
    
    class PodcastPersonController extends BaseController
    
        public function _remap(string $method, string ...$params): mixed
    
            if ($params === []) {
    
                ($podcast = (new PodcastModel())->getPodcastById((int) $params[0])) instanceof Podcast
    
                return $this->{$method}($podcast, ...$params);
    
        public function index(Podcast $podcast): string
    
                'podcast'         => $podcast,
                'podcastPersons'  => (new PersonModel())->getPodcastPersons($podcast->id),
    
                'personOptions'   => (new PersonModel())->getPersonOptions(),
    
                'taxonomyOptions' => (new PersonModel())->getTaxonomyOptions(),
            ];
    
    
            $this->setHtmlHead(lang('Person.podcast_form.title'));
    
            replace_breadcrumb_params([
    
            return view('podcast/persons', $data);
    
        public function createAction(Podcast $podcast): RedirectResponse
    
                return redirect()
                    ->back()
                    ->withInput()
                    ->with('errors', $this->validator->getErrors());
            }
    
    
            (new PersonModel())->addPodcastPersons(
    
        public function deleteAction(Podcast $podcast, string $personId): RedirectResponse
    
            (new PersonModel())->removePersonFromPodcast($podcast->id, (int) $personId);