createItem() public method

Create a new category item
public createItem ( Category $category, array $inputs ) : CategoryItem
$category Xpressengine\Category\Models\Category category instance
$inputs array item attributes for created
return Xpressengine\Category\Models\CategoryItem
コード例 #1
0
 public function storeItem(CategoryHandler $handler, $categoryId)
 {
     $category = $handler->get($categoryId);
     $inputs = Input::except('_token');
     $parent = null;
     if (isset($inputs['parentId'])) {
         if (empty($inputs['parentId']) === false) {
             $parent = $handler->getItem($inputs['parentId']);
         }
         unset($inputs['parentId']);
     }
     DB::beginTransaction();
     try {
         $item = $handler->createItem($category, $inputs, $parent);
     } catch (Exception $e) {
         DB::rollBack();
         throw $e;
     }
     DB::commit();
     return Presenter::makeApi($item->toArray());
 }