Store category in the database.

@param \Modules\Category\Models\CategoryGroup $categoryGroup
@param \Modules\Category\Http\Requests\CategoryRequest $request
@return \Illuminate\Http\JsonResponse
339274
public function store(CategoryGroup $categoryGroup, CategoryRequest $request): JsonResponse
    {
        $category = $categoryGroup->categories()->create(
            $request->only('icon')
        );

        foreach ($request->file('icons', []) as $key => $file) {
            if ($categoryGroup->hasFileIcon($key) && $file) {
                $category->icons()->create([
                    'key'  => $key,
                    'icon' => $file,
                ]);
            }
        }

        $this->modifySlugs($request);

        $category->storeTranslations(
            $request->input('translations')
        );

        if ($request->has('parent_id') && $parent = Category::find($request->input('parent_id'))) {
            $parent->appendNode($category);
        }

        dispatch(
            new RegenerateCategoryFullSlugs($category)
        );

        $this->clearCache();

        return response()->json([
            'state' => 'success',
        ]);
    }
915146
public function store(Request $request)
    {
        // Carregar objeto JSON
        $obj = $this->getJsonContent($request);
        if (is_null($obj)) {
            $this->error('JSON invalid', 500);
        }

        // Salvar
        $model = $this->setValues($obj);

        return response()->json($model);
    }
1206641
public function cdeleteAction($categoryId, Request $request)
    {
        $category = $this->getCategoryRepository()->findCategoryById($categoryId);

        $ids = array_filter(explode(',', $request->get('ids')));
        foreach ($ids as $id) {
            $keyword = $this->getKeywordRepository()->findById($id);
            $this->getKeywordManager()->delete($keyword, $category);
        }

        $this->getEntityManager()->flush();

        return $this->handleView($this->view());
    }
1148766
public function store(UserGroupRequest $request)
    {
        $this->_syncIsDefault();
        $this->repository->create($request->all());

        return redirect()->route('admin.user-group.index');
    }
1243604
private function storeOrUpdateCategory($request)
    {
        $cat = $this->category->whereName($request->name)->first();

        if (count($cat) > 0) {
            $category = $cat;
        } else {
            $category = new Category;
            $category->hash = $this->blogify->makeHash('categories', 'hash', true);
        }

        $category->name = $request->name;
        $category->save();

        return $category;
    }
874501
protected function setCategory($category_id)
    {
        $options = array(
            'category_id' => $category_id,
            'language' => $this->langcode,
            'store_id' => $this->store_id
        );

        $this->data_category = $this->category->get($options);

        if (empty($this->data_category['status'])) {
            $this->outputHttpStatus(404);
        }

        $this->prepareCategory($this->data_category);
    }
752711
public function sortCategories(Request $request)
    {
        $this->validate(
            $request,
            [
                'categories' => 'required|array',
            ]
        );

        foreach ($request->input('categories') as $category_id => $sort) {
            $category = Category::find($category_id);

            $category->sort = $sort;

            $category->save();
        }

        return redirect()->back()->withStatus(trans('mustard::admin.categories_sorted'));
    }
89630
public function update(Request $request)
    {
        $this->cache->tags('categories')->flush();

        $this->categoryOrdener->handle($request->get('categories'));
    }
436312
public function updateCategory(Request $request)
    {
        $this->validate(
            $request,
            [
                'category_id'        => 'required|integer|exists:categories',
                'parent_category_id' => 'integer|exists:categories,category_id',
                'name'               => 'required',
                'slug'               => 'required',
            ]
        );

        $category = Category::find($request->input('category_id'));

        $parent = Category::find($request->input('parent_category_id'));

        if (in_array($request->input('parent_category_id'), $category->getDescendantIds())) {
            return redirect()->back()->withErrors(['parent_category_id' => trans('mustard::admin.category_parent_is_child')]);
        }

        $category->parent()->associate($parent);
        $category->name = $request->input('name');
        $category->slug = $request->input('slug');

        $category->save();

        return redirect()->back()->withStatus(trans('mustard::admin.category_updated'));
    }
565039
public function setCategoryConfig($categoryConfig = '')
    {
        $this->categoryConfig = $categoryConfig;
        $this->logger->info(__FUNCTION__, 'setCategoryConfig: ' . json_encode($this->categoryConfig));
    }
339841
public function store(CategoriesFormRequest $request, Category $category)
    {
        $category->fill($request->all());
        $category->published     = $request->get('published', false);
        $category->authenticated = $request->get('authenticated', false);
        $category->save();
        flash()->success(trans('cms::categories.store.success'));

        return redirect()->route('administrator.categories.index');
    }
1022353
public function show(Category $category, Request $request)
    {
        $category->increment('hits');

        $layout   = $request->query('layout', 'blog');
        $limit    = $request->get('limit', $layout == 'list' ? 10 : 6);
        /** @var \Illuminate\Contracts\Pagination\Paginator $articles */
        $articles = $category->articles()->published()->isNotPage()->latest()->paginate($limit);

        if ($layout === 'list') {
            $articles->appends('layout', 'list');
        }

        if ($request->has('limit')) {
            $articles->appends('limit', $limit);
        }

        event(new CategoryWasViewed($category));

        return view("category.$layout", compact('category', 'articles', 'limit'));
    }
303216
protected function process(FormRequest $request, Category $category)
    {
        // Prepare required input fields
        $data = $request->validated();

        // Save category
        $category->fill($data)->save();

        return intend([
            'url' => route('adminarea.categories.index'),
            'with' => ['success' => trans('cortex/foundation::messages.resource_saved', ['resource' => trans('cortex/categories::common.category'), 'identifier' => $category->name])],
        ]);
    }
1252795
public function store(Create $request)
    {
        $data = $request->all();

        $category = Category::create($data);

        return $this->redirect('categories.index');
    }
761505
protected function submitAddCategoryGroup()
    {
        $this->setSubmitted(null, $this->getParam());
        $this->validateComponent('category_group');
        $this->addCategoryGroup();
    }
1054909
public function store(MenuRequest $request)
    {
        $menuGroup = $this->menuGroupRepository
            ->find($request->get('menu_group_id'));
        if (null === $menuGroup) {
            $menuGroup = $this->menuGroupRepository->create($request->all());
        } else {
            $menuGroup->update($request->all());
        }
        $menuJson = $request->get('menu_json');
        $menuArray = json_decode($menuJson, true);
        
        $this->repository->truncateAndCreateMenus($menuGroup, $menuArray);

        return redirect()->route('admin.menu.index')
            ->with('notificationText', 'Menu Save Successfully!!');
    }
338189
public function show(CategoryRequest $request, Category $category)
    {

        if ($category->exists) {
            $view = 'block::admin.category.show';
        } else {
            $view = 'block::admin.category.new';
        }

        return $this->response->setMetaTitle(trans('app.view') . ' ' . trans('block::category.name'))
            ->data(compact('category'))
            ->view($view)
            ->output();
    }