Example #1
0
 /**
  * Add example walkthroughs
  *
  * @return $this
  */
 protected function _addWalkthroughs()
 {
     $count = 0;
     echo 'Adding Walkthroughs: ';
     $categories = Category::collection();
     foreach ($categories as $category) {
         $walkthroughTitles = $this->_getTitleArray('Walkthrough', rand(1, 3));
         foreach ($walkthroughTitles as $walkthroughTitle) {
             $walkthrough = new Walkthrough();
             $walkthrough->categoryId = $category->id();
             $walkthrough->title = $walkthroughTitle;
             $walkthrough->slug = Strings::urlize($walkthroughTitle);
             $walkthrough->subTitle = $this->_getExampleContent(rand(4, 8));
             $walkthrough->description = $this->_getExampleContent(rand(10, 20));
             $walkthrough->saveChanges();
             $stepTitles = $this->_getTitleArray(rand(3, 6));
             $stepOrder = 1;
             foreach ($stepTitles as $stepTitle) {
                 $step = new WalkthroughStep();
                 $step->title = sprintf('Step %d: %s', $stepOrder, $stepTitle);
                 $step->slug = Strings::urlize($stepTitle);
                 $step->walkthroughId = $walkthrough->id();
                 $step->content = $this->_getExampleContent(rand(30, 50));
                 $step->order = $stepOrder;
                 $step->saveChanges();
                 $stepOrder++;
             }
             $count++;
         }
     }
     echo $count . PHP_EOL;
     return $this;
 }
Example #2
0
 private function _getWalkthroughStepUrl(WalkthroughStep $walkthroughStep)
 {
     $walkthrough = $walkthroughStep->getWalkthrough();
     $url = sprintf('%s/%d-%s', $this->getUrl($walkthrough), $walkthroughStep->id(), $walkthroughStep->slug);
     return $url;
 }