Exemplo n.º 1
0
 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();
 }
Exemplo n.º 2
0
 /**
  * @return ArticleSection[]|RecordCollection
  */
 public function getArticleSections()
 {
     $sections = ArticleSection::collection(['article_id' => $this->id()]);
     return $sections->setOrderBy('order');
 }
 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;
 }
Exemplo n.º 4
0
 /**
  * Add example articles
  *
  * @return $this
  */
 protected function _addArticles()
 {
     echo 'Adding Articles: ';
     $count = 0;
     /** @var Category[] $categories */
     $categories = Category::collection();
     /** @var Platform[] $platforms */
     $platforms = Platform::collection();
     foreach ($categories as $category) {
         $articleTitles = $this->_getTitleArray('Article', rand(1, 3));
         foreach ($articleTitles as $articleTitle) {
             $article = new Article();
             $article->categoryId = $category->id();
             $article->title = $articleTitle;
             $article->slug = Strings::urlize($articleTitle);
             $article->subTitle = $this->_getExampleContent(rand(4, 20));
             $article->saveChanges();
             $blockCount = rand(2, 6);
             $i = 0;
             do {
                 $section = new ArticleSection();
                 $section->articleId = $article->id();
                 $section->saveChanges();
                 foreach ($platforms as $platform) {
                     $block = new ArticleSectionBlock();
                     $block->articleSectionId = $section->id();
                     $block->platformId = $platform->id();
                     $block->title = $this->_getExampleContent(3);
                     $block->content = $this->_getExampleContent(rand(10, 30));
                     $block->saveChanges();
                 }
                 $i++;
             } while ($i <= $blockCount);
             $count++;
         }
     }
     echo $count . PHP_EOL;
     return $this;
 }