Store a newly created resource in storage.

@param  \Yajra\CMS\Http\Requests\CategoriesFormRequest $request
@param  \Yajra\CMS\Entities\Category $category
@return \Illuminate\Http\Response
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');
    }
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'));
    }
164380
public function store(FormRequest $request)
    {
        $data = $request->all();
        $model = $this->repository->create($data);

        return $this->redirect($request, $model);
    }
205979
public function store(CategoriesRequest $request)
    {
        $category = Category::create(
            $request->all()
        );

        return redirect()->route('categories.edit', $category)->with(
            'status', trans('globals.success_text')
        );
    }
291832
public function update(CreateCategoryRequest $request, $id)
	{
        $category = $this->model->findOrFail($id);
        if($category->name !== $request->get('name')){
            $category->generateNewSlug = true;
        }
        $category->fill($request->all());
        $category->save();
        flash()->success('Se ha actualizado la Categoria');
        return redirect()->to('backend/blog-categories');
	}
1341165
public function store(Request $request)
    {
        $category = $this->api('category.store')->parameters($request->all())->post();

        Forum::alert('success', 'categories.created');

        return redirect(Forum::route('category.show', $category));
    }
891998
public function store(CategoryRequest $request)
    {
        try {
            $attributes              = $request->all();
            $attributes['user_id']   = user_id();
            $attributes['user_type'] = user_type();
            $category                 = $this->repository->create($attributes);

            return $this->response->message(trans('messages.success.created', ['Module' => trans('faq::category.name')]))
                ->code(204)
                ->status('success')
                ->url(guard_url('faq/category/' . $category->getRouteKey()))
                ->redirect();
        } catch (Exception $e) {
            return $this->response->message($e->getMessage())
                ->code(400)
                ->status('error')
                ->url(guard_url('/faq/category'))
                ->redirect();
        }

    }
199282
public function publish(Category $category)
    {
        $category->togglePublishedState();

        $category->getDescendants()->each(
            function (Category $cat) use ($category) {
                $cat->published = $category->published;
                $cat->save();
            }
        );

        $message = $category->published ? trans('cms::categories.publish.success') : trans('cms::categories.publish.error');

        return $this->notifySuccess($message);
    }
1245633
public function index(CategoryRequest $request)
    {
        $view = $this->response->theme->listView();

        if ($this->response->typeIs('json')) {
            $function = camel_case('get-' . $view);
            return $this->repository
                ->setPresenter(\Litecms\Faq\Repositories\Presenter\CategoryPresenter::class)
                ->$function();
        }

        $categories = $this->repository->paginate();

        return $this->response->title(trans('faq::category.names'))
            ->view('faq::category.index', true)
            ->data(compact('categories'))
            ->output();
    }
146377
private function createDeleteForm(Category $category)
    {
        return $this->createFormBuilder()
            ->setAction($this->generateUrl('ecommerce_category_delete', array('id' => $category->getId())))
            ->setMethod('DELETE')
            ->getForm()
        ;
    }
99598
public static function save_category(category_controller $category) {
        $isnewcategory = empty($category->get('id'));

        $category->save();

        if ($isnewcategory) {
            // Move to the end.
            self::move_category($category);
            category_created::create_from_object($category)->trigger();
        } else {
            category_updated::create_from_object($category)->trigger();
        }
    }
440308
public function addCategorie(\Haven\CoreBundle\Entity\Category $categories)
    {
        $this->categories[] = $categories;
    
        return $this;
    }
347744
public function update(CategoryRequest $request, CategoryGroup $categoryGroup, Category $category): JsonResponse
    {
        if ($category->category_group_id !== $categoryGroup->id) {
            abort(404);
        }

        $category->update(
            $request->only('icon')
        );

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

        $this->modifySlugs($request);

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

        dispatch(
            new RegenerateCategoryFullSlugs($category)
        );

        $this->clearCache();

        return response()->json([
            'state' => 'success',
        ]);
    }
1079689
public function destroy(CategoryRequest $request, Category $category)
    {
        try {

            $category->delete();
            return $this->response->message(trans('messages.success.deleted', ['Module' => trans('faq::category.name')]))
                ->code(202)
                ->status('success')
                ->url(guard_url('faq/category/0'))
                ->redirect();

        } catch (Exception $e) {

            return $this->response->message($e->getMessage())
                ->code(400)
                ->status('error')
                ->url(guard_url('faq/category/' . $category->getRouteKey()))
                ->redirect();
        }

    }
681276
public function setCategory(\Innova\LexiconBundle\Entity\Category $category = null)
    {
        $this->category = $category;

        return $this;
    }
1303983
public function cgetAction($categoryId, Request $request)
    {
        /** @var RestHelperInterface $restHelper */
        $restHelper = $this->get('sulu_core.doctrine_rest_helper');

        /** @var DoctrineListBuilderFactory $factory */
        $factory = $this->get('sulu_core.doctrine_list_builder_factory');

        /** @var CategoryInterface $category */
        $category = $this->getCategoryRepository()->find($categoryId);

        $fieldDescriptor = $this->getFieldDescriptors();

        $listBuilder = $factory->create($this->getParameter('sulu.model.keyword.class'));
        $restHelper->initializeListBuilder($listBuilder, $fieldDescriptor);

        $listBuilder->where($fieldDescriptor['locale'], $request->get('locale'));
        $listBuilder->where(
            $fieldDescriptor['categoryTranslationIds'],
            $category->findTranslationByLocale($request->get('locale'))
        );

        // should eliminate duplicates
        $listBuilder->distinct(true);
        $listBuilder->addGroupBy($fieldDescriptor['id']);

        $listResponse = $listBuilder->execute();

        $list = new ListRepresentation(
            $listResponse,
            self::$entityKey,
            'get_category_keywords',
            array_merge(['categoryId' => $categoryId], $request->query->all()),
            $listBuilder->getCurrentPage(),
            $listBuilder->getLimit(),
            $listBuilder->count()
        );

        return $this->handleView($this->view($list, 200));
    }
624705
public function make(ICategory $category)
    {
        //$category->setResponse($this->response->view('admin.categorys.view', compact('category')));
        $category->setResponse($this->response->view(\OogleeBConfig::get('config.category_view.view'), compact('category')));
    }