Save Category in database.

@param  Request $request
@return array
@throws \Exception
760414
public function store(Request $request)
    {
        // check if user has permissions to access this link
        if(!User::hasAccess('Categories', 'create')) {
            return $this->noPermission();
        }

        $data = $request->all();
        $structuredData =  $this->generateTitleAndSlug($data['form']);
        $form = $structuredData['form'];
        $errors = $structuredData['errors'];

        // return errors if there are any
        if(count($errors)) {
            return $this->response("From errors", 400, null, false, false, true, $errors);
        }

        // if category is being created
        if(!isset($form['categoryID'])) {
            // Order item
            $catCount = Category::where("postTypeID", $request->postTypeID)->count();
            $order = $catCount+1;
            $categoryModel = new Category();
        }else{
            // if category is being updated
            $categoryModel = Category::find($form['categoryID']);
            if(!$categoryModel) {
                return $this->response("Category doesn't exist", 500);
            }
            $order = $categoryModel->order;
            $oldTitle = $categoryModel->setAutoTranslate(false)->title;
        }

        // parent ID
        $parentID = 0;
        if(isset($form['parent']['categoryID'])) {
            $parentID = $form['parent']['categoryID'];
        }

        // Create Category
        $categoryModel->title = $form['title'];
        $categoryModel->postTypeID = $data['postTypeID'];
        $categoryModel->parentID = ($parentID ? $parentID: null);
        $categoryModel->featuredImageID = $form['featuredImageID'];
        $categoryModel->description = $form['description'];
        $categoryModel->slug = $form['slug'];
        $categoryModel->isVisible = $form['isVisible'];
        $categoryModel->order = $order;
        $categoryModel->createdByUserID = Auth::user()->userID;
        $categoryModel->customFields = $request->customFieldValues;

        // return results
        if ($categoryModel->save()) {
            if(isset($form['categoryID'])) {
                // update label in menu link with the category title
                $this->updateMenuLinkLabel($data['id'], $form['title'], $oldTitle);
            }
            $redirect = $this->redirect($request->redirect, $categoryModel->categoryID, $data['postTypeID']);
            $response = $this->response('Category is saved', 200, $redirect['id'], $redirect['view'], $redirect['url']);
        }else{
            $response = $this->response('Category is not saved. Please try again later!', 500);
        }
        return $response;
    }
1108375
public function index(Request $request)
    {
        $categories = $this->category->all();

        return Response::json(['errors' => false, 'data' => $categories]);
    }
684407
public function store(Request $request)
    {
        try {
            $field = $this->fields->save($request);
        } catch (Exception $e) {
            return $this->handleException($e, trans('soda::errors.create', ['object' => trans('soda::terminology.field')]));
        }

        return redirect()->route('soda.fields.edit', $field->getKey())->with('success', trans('soda::messages.created', ['object' => trans('soda::terminology.field')]));
    }
839069
public function store(Request $request)
    {
        $query = $this->getQuery();

        try {
            if ($request->input('query')) {
                $filter = new Filter($this->manager->newEntity()->getTable(), $this->queryable);
                $filter->build($query, $request->input('query'));
            }
        } catch (QuerySyntaxException $e) {
            return $this->error(['code' => 'QUERY_SYNTAX_ERROR', 'message' => 'Syntax error']);
        }

        $params = $request->only($this->fillable);

        DB::beginTransaction();

        $result = new Result();

        $query->chunk(100, function ($resources) use ($params, &$result) {
            foreach ($resources as $resource) {
                $result->addErrors($this->getManager()->update($resource, $params)->getErrors());
            }
        });

        if (!$result->ok()) {
            DB::rollBack();

            return $this->response(['errors' => $result->getSimpleErrors()], Response::HTTP_BAD_REQUEST);
        }

        DB::commit();

        return $this->response(null, Response::HTTP_OK);
    }
913718
public function store(Request $request)
    {
        app()->make('Request')->setRequest($request->toArray());
        $scaffold = app()->make('Scaffold');
        $relations = app()->make('Datasystem');
        $scaffold->model()->views()->controller()->migration()->route();
        $paths = app()->make('Path');
        $names = app()->make('Parser');

        $scaffoldInterface = Scaffoldinterface::create([
            'migration'  => $paths->migrationPath,
            'model'      => $paths->modelPath(),
            'controller' => $paths->controllerPath(),
            'views'      => $paths->dirPath(),
            'tablename'  => $names->plural(),
            'package'    => config('amranidev.config.package'),
        ]);

        if ($relations->getForeignKeys()) {
            foreach ($relations->getForeignKeys() as $foreignKey) {
                $record = DB::table('scaffoldinterfaces')->where('tablename', $foreignKey)->first();
                Relation::create(['scaffoldinterface_id' => $scaffoldInterface->id,
                    'to'                                 => $record->id,
                    'having'                             => Relation::ONE_TO_MANY,
                ]);
            }
        }

        Session::flash('status', 'Created Successfully '.$names->singular());

        return redirect('scaffold');
    }
1179036
public function save(\Illuminate\Http\Request $request)
    {
        if (($content = $this->getContent()) instanceof FormElementInterface) {
            $content->save($request);
        }
    }
1083157
public function store(Request $request)
    {
        $category = $this->api('category.fetch', $request->route('category'))->get();

        if (!$category->threadsEnabled) {
            Forum::alert('warning', 'categories.threads_disabled');

            return redirect(Forum::route('category.show', $category));
        }

        $thread = [
            'author_id'     => auth()->user()->getKey(),
            'category_id'   => $category->id,
            'title'         => $request->input('title'),
            'content'       => $request->input('content')
        ];

        $thread = $this->api('thread.store')->parameters($thread)->post();

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

        return redirect(Forum::route('thread.show', $thread));
    }
995258
public function saveAction(Request $request)
    {
        $repository = $this->get('phlexible_media_template.template_manager');

        $templateKey = $request->get('template_key');
        $params = $request->request->all();

        unset($params['template_key'],
        $params['module'],
        $params['controller'],
        $params['action']);

        $template = $repository->find($templateKey);

        $params = $this->fixParams($params);

        foreach ($params as $key => $value) {
            $template->setParameter($key, $value);
        }

        $repository->updateTemplate($template);

        return new ResultResponse(true, 'Media template "'.$template->getKey().'" saved.');
    }
120322
public function store(Request $request)
    {
        try {
            $permission = $this->permissions->save($request);
        } catch (Exception $e) {
            return $this->handleException($e, trans('soda::errors.create', ['object' => 'permission']));
        }

        return redirect()->route('soda.permissions.edit', $permission->getKey())->with('success', trans('soda::messages.created', ['object' => 'permission']));
    }
197688
public function store(Request $request)
    {
        $this->validate($request, $this->validationRules($this->resource));
        $entry = $this->entriesRepository->create($request, $this->resource);

        return redirect('admin/' . $this->resource->slug)->with('success', 'Added');
    }
1164200
public function store(Request $request)
    {
        $menu = Dashboard::model(Menu::class)::create(array_merge($request->input('params.data'), [
            'lang'   => $request->input('params.lang'),
            'type'   => $request->input('params.menu'),
            'parent' => 0,
        ]));

        return response()->json([
            'type' => 'success',
            'id'   => $menu->id,
        ]);
    }
1035867
public function save(\Illuminate\Http\Request $request)
    {
        $name = $this->getName();
        $value = $request->input($name, '');

        if (! empty($value)) {
            $value = explode(',', $value);
        } else {
            $value = [];
        }

        $request->merge([$name => $value]);

        parent::save($request);
    }
271916
public function store(Request $request)
    {
        $this->validate($request, $this->rules);

        //VARIABLES
        $titulo = $request->input('titulo');
        $slug_url = SlugUrl($titulo);
        $categoria = $request->input('categoria');
        $tags = $request->input('tags');

        //GUARDAR DATOS
        $post = new Noticia($request->all());
        $post->slug_url = $slug_url;
        $post->user_id = auth()->user()->id;
        $post->categoria_id = $categoria;
        $row = $this->noticiaRepo->create($post, $request->all());

        ($tags <> '') ? $row->tags()->sync($tags) : false;

        //MENSAJE
        flash()->success('El registro se agregó satisfactoriamente.');

        //REDIRECCIONAR A PAGINA PARA VER DATOS
        return redirect()->route('admin.noticias.index');
    }
1170192
public function store(Request $request)
    {
        $this->authorize('store', MemberCategory::class);
        /** @noinspection PhpUndefinedMethodInspection */
        $request->validate([
            "name" => "required|max:36",
            "description" => "required|max:128",
        ]);
        $memberCategory = new MemberCategory;
        $memberCategory->team_id = $this->userContext()->team_id;
        $memberCategory->name = $request->name;
        $memberCategory->description = $request->description;
        $memberCategory->save();
        return fractal($memberCategory, new MemberCategoryTransformer())
            ->withResourceName('memberCategory')
            ->respond();
    }
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');
    }
678058
public function saveAction(Request $request)
    {
        $language = $request->get('language');

        $iconResolver = $this->get('phlexible_element.icon_resolver');
        $dataSaver = $this->get('phlexible_element.request.data_saver');

        /* @var $treeNode TreeNodeInterface */
        list($elementVersion, $treeNode, $teaser, $publishSlaves, $status) = $dataSaver->save(
            $request,
            $this->getUser()
        );

        if ($teaser) {
            $icon = $iconResolver->resolveTeaser($teaser, $language);
        } else {
            $icon = $iconResolver->resolveTreeNode($treeNode, $language);
        }

        $msg = "Element {$elementVersion->getElement()->getEid()} master language {$elementVersion->getElement()->getMasterLanguage()} saved as new version {$elementVersion->getVersion()}";

        $data = [
            'title' => $elementVersion->getBackendTitle($language),
            'icon' => $icon,
            'navigation' => $teaser ? '' : $treeNode->getInNavigation(),
            'restricted' => $teaser ? '' : $treeNode->getAttribute('needAuthentication'),
            'publish_other' => $publishSlaves,
            'publish' => $request->get('isPublish') ? true : false,
            'status' => $status,
        ];

        return new ResultResponse(true, $msg, $data);
    }
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();
    }