Example #1
0
 public function postEdit()
 {
     $postData = $this->request()->postVariables();
     $newCategory = new Category();
     $newCategory->hydrateFromUnserialized($postData);
     $newCategory->saveChanges();
     Redirect::to('/' . $this->baseUri())->with('msg', new TransportMessage('success', 'Category was successfully updated'))->now();
 }
Example #2
0
 /**
  * Add example categories
  *
  * @return $this
  */
 protected function _addCategories()
 {
     // Add parent categories
     echo 'Adding Categories: ';
     $count = 0;
     //$categoryTitles = $this->_getTitleArray('Category', rand(2, 4));
     $platforms = Platform::collection();
     foreach ($platforms as $platform) {
         $category = new Category();
         $category->title = $platform->name;
         $category->slug = Strings::urlize($platform->name);
         $category->subTitle = $this->_getExampleContent();
         $category->description = $this->_getExampleContent(rand(5, 15));
         $category->saveChanges();
         $count++;
     }
     echo $count . PHP_EOL;
     // Add sub-categories
     echo 'Adding Sub-Categories: ';
     $count = 0;
     $categories = Category::collection();
     foreach ($categories as $category) {
         $subCategoryCount = rand(1, 2);
         $categoryTitles = $this->_getTitleArray('Category', $subCategoryCount);
         foreach ($categoryTitles as $categoryTitle) {
             $subCategory = new Category();
             $subCategory->parentCategoryId = $category->id();
             $subCategory->title = $categoryTitle;
             $subCategory->slug = Strings::urlize($categoryTitle);
             $subCategory->subTitle = $this->_getExampleContent(rand(5, 15));
             $subCategory->saveChanges();
             $count++;
         }
     }
     echo $count . PHP_EOL;
     return $this;
 }