Skip to content
Snippets Groups Projects
PodcastPersonController.php 2.13 KiB
Newer Older
  • Learn to ignore specific revisions
  • <?php
    
    /**
     * @copyright  2020 Podlibre
     * @license    https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
     * @link       https://castopod.org/
     */
    
    namespace App\Controllers\Admin;
    
    
    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 (count($params) === 0) {
                throw PageNotFoundException::forPageNotFound();
    
                ($this->podcast = (new PodcastModel())->getPodcastById((int) $params[0],)) !== null
    
        public function index(): string
    
        {
            helper('form');
    
            $data = [
                'podcast' => $this->podcast,
    
                'podcastPersons' => (new PersonModel())->getPodcastPersons($this->podcast->id,),
    
                'personOptions' => (new PersonModel())->getPersonOptions(),
                'taxonomyOptions' => (new PersonModel())->getTaxonomyOptions(),
            ];
            replace_breadcrumb_params([
                0 => $this->podcast->title,
            ]);
    
        public function attemptAdd(): RedirectResponse
    
                return redirect()
                    ->back()
                    ->withInput()
                    ->with('errors', $this->validator->getErrors());
            }
    
    
            (new PersonModel())->addPodcastPersons(
    
                $this->request->getPost('persons'),
                $this->request->getPost('roles') ?? [],
    
        public function remove(int $personId): RedirectResponse
    
            (new PersonModel())->removePersonFromPodcast($this->podcast->id, $personId,);