public function renderDestroy() { $articleId = $this->getInt('id'); $article = new Article($articleId); $article->delete(); $sections = ArticleSection::collection(['article_id' => $articleId]); foreach ($sections as $section) { $articleSection = new ArticleSection($section->id()); $articleSection->delete(); $sectionBlocks = ArticleSectionBlock::collection(['article_section_id' => $section->id()]); foreach ($sectionBlocks as $block) { $block->delete(); } } Redirect::to('/' . $this->baseUri())->with('msg', new TransportMessage('success', 'Article was successfully deleted'))->now(); }
public function renderDestroy() { $sectionId = $this->getInt('id'); $articleSection = new ArticleSection($sectionId); $articleSection->delete(); $sectionBlocks = ArticleSectionBlock::collection(['article_section_id' => $sectionId]); foreach ($sectionBlocks as $block) { $block->delete(); } Redirect::to('/admin/article/' . $articleSection->articleId . '/edit')->now(); die; }