Skip to content
Snippets Groups Projects
EpisodePersonController.php 2.55 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\EpisodeModel;
    use App\Models\PersonModel;
    
    use App\Models\PodcastModel;
    use CodeIgniter\Exceptions\PageNotFoundException;
    use CodeIgniter\HTTP\RedirectResponse;
    
    class EpisodePersonController extends BaseController
    
        public function _remap(string $method, string ...$params): mixed
    
                ($this->podcast = (new PodcastModel())->getPodcastById((int) $params[0])) &&
    
                        'podcast_id' => $params[0],
                    ])
                    ->first())
            ) {
                unset($params[1]);
                unset($params[0]);
    
    
        public function index(): string
    
                'episode'         => $this->episode,
                'podcast'         => $this->podcast,
                'personOptions'   => (new PersonModel())->getPersonOptions(),
    
                'taxonomyOptions' => (new PersonModel())->getTaxonomyOptions(),
            ];
            replace_breadcrumb_params([
    
                1 => $this->episode->title,
            ]);
    
            return view('episode/persons', $data);
    
        public function attemptAdd(): RedirectResponse
    
                return redirect()
                    ->back()
                    ->withInput()
                    ->with('errors', $this->validator->getErrors());
            }
    
    
            (new PersonModel())->addEpisodePersons(
    
                $this->podcast->id,
                $this->episode->id,
    
                $this->request->getPost('persons'),
                $this->request->getPost('roles') ?? [],
    
        public function remove(string $personId): RedirectResponse
    
            (new PersonModel())->removePersonFromEpisode($this->podcast->id, $this->episode->id, (int) $personId);