From dffb676ed84d5b3bc6a9629851866ab20f8a99dd Mon Sep 17 00:00:00 2001 From: Daniel Wilkowski Date: Thu, 25 Jan 2024 18:20:56 +0100 Subject: [PATCH] Correct CategoriesController.edit() --- .../Controllers/Adm/Forum/CategoriesController.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/Adm/Forum/CategoriesController.php b/app/Http/Controllers/Adm/Forum/CategoriesController.php index e931b5ec50..1463392c92 100644 --- a/app/Http/Controllers/Adm/Forum/CategoriesController.php +++ b/app/Http/Controllers/Adm/Forum/CategoriesController.php @@ -4,6 +4,7 @@ use Boduch\Grid\Source\CollectionSource; use Coyote\Events\ForumSaved; +use Coyote\Forum; use Coyote\Http\Controllers\Adm\BaseController; use Coyote\Http\Forms\Forum\ForumForm; use Coyote\Http\Grids\Adm\Forum\CategoriesGrid; @@ -45,10 +46,15 @@ public function index(): View return $this->view('adm.forum.categories.home')->with('grid', $grid); } - public function edit(?int $id): View + public function edit(int $id = null): View { - $forum = $this->forum->findOrNew($id); - $this->breadcrumb->push($forum->name ?? 'Dodaj nowÄ…', route('forum.category', ['forum' => $forum])); + if ($id) { + $forum = $this->forum->findOrNew($id); + $this->breadcrumb->push($forum->name, route('forum.category', ['forum' => $forum])); + } else { + $forum = new Forum; + $this->breadcrumb->push('Dodaj nowÄ…', route('adm.forum.categories.save')); + } return $this->view('adm.forum.categories.save')->with('form', $this->getForm($forum)); }