Create a category.

@return \Illuminate\Http\RedirectResponse
515274
public function createCategory(Request $request)
    {
        $this->validate(
            $request,
            [
                'parent_category_id' => 'integer|exists:categories',
                'name'               => 'required',
                'slug'               => 'required',
            ]
        );

        $category = new Category();

        $category->parentCategoryId = $request->input('parent_category_id');
        $category->name = $request->input('name');
        $category->slug = $request->input('slug');

        $category->save();

        return redirect()->back()->withStatus(trans('mustard::admin.category_created'));
    }
1321940
public function category(Category $category)
    {
        $this->_category = $category;

        $this->joinWith('categories');
        $this->andFilterWhere([$category::tableName().'.id' => $this->_category->id]);

        return $this;
    }
411252
protected function createComponentCategoryRemoveModal() : object
    {
        $control = $this->ICategory_RemoveModal->create();

        $control->onRemove[] = function ()
        {
            $this->getComponent('categoryModal')->redrawControl('modal'); // SA
            $this->getComponent('categoryModal')->redrawControl('form');
            $this->getComponent('categoryModal')->redrawControl('summary');

            $this->getComponent('structureRecipeModal')->redrawControl('form');
        };

        $control->onOpen[] = function () use ($control)
        {
            $control->redrawControl('modal');
        };

        return $control;
    }
481879
public function create()
    {
        $this->loadModel('Content.ContentTypes');
        $types = $this->ContentTypes->find()
            ->select(['id', 'slug', 'name', 'description'])
            ->all();

        $this->title(__d('content', 'Create New Content'));
        $this->set('types', $types);
        $this->Breadcrumb
            ->push('/admin/content/manage')
            ->push(__d('content', 'Create new content'), '');
    }
584840
public function create() {
        $categories = $this->repository->getAll();

        return view('lasallecmsadmin::'.config('lasallecmsadmin.admin_template_name').'/categories/create',[
            'pagetitle'                      => 'Categories',
            'field_list'                     => $this->model->field_list,
            'namespace_formprocessor'        => $this->model->namespace_formprocessor,
            'classname_formprocessor_create' => $this->model->classname_formprocessor_create,
            'DatesHelper'                    => DatesHelper::class,
            'Form'                           => Form::class,
            'HTMLHelper'                     => HTMLHelper::class,
            'categories'                     => $categories,
            'admin_size_input_text_box'      => Config::get('lasallecmsadmin.admin_size_input_text_box'),
        ]);
    }
241780
public function create()
    {
        if (\Auth::user()->id == 1 || \Auth::user()->id == 2) {
            return view('adminems::users.create');
        }

        return redirect()->route('panel');
        
    }
469276
public function category() {
		global $cat;

		$category = get_category( $cat );
		if ( $category->parent != 0 ) {
			$ancestors = array_reverse( get_ancestors( $category->term_id, 'category') );
			foreach ( $ancestors as $ancestor_id ) {
				$ancestor = get_category( $ancestor_id );
				$this->addCrumb( $ancestor->name, get_category_link( $ancestor->term_id ) );
			}
		}
		$this->addCrumb( $this->label('category', $category->name ), get_category_link( $cat ) );
	}
645219
public function create()
    {
        /**
         * @var Category $category
         */
        $classNamespace = $this->getEntityNamespace();
        $category = new $classNamespace();
        $category
            ->setSubcategories(new ArrayCollection())
            ->setRoot(true)
            ->setPosition(0)
            ->setEnabled(true)
            ->setCreatedAt($this->now());

        return $category;
    }
1149187
public function insert (Request $request)
    {
        if ($this->category->categoryExist($request->input('title') , $request->input('model_type')))
            throw new CategoryException(trans('Categories::category.error-message.categoryExist'));

        $category = $this->category->newInstance($request->except('_token'));
        $slug = new Slugger($this->modelType);
        $category->slug = $slug->storeSlug($request->input('slug') , $request->input('title'));
        $category->model_type = $this->modelType;
        $category->save();

        return $category;

    }
700546
private function loadCategory()
    {
        $category   = $this->categoryFactory->create();
        $storeId    = $this->getRequest()->getParam('store');
        $categoryId = $this->getRequest()->getParam('entity_id');

        $category->setStoreId($storeId)->load($categoryId);

        return $category;
    }
345192
public function store(CategoryRequest $request)
    {
        $category = Category::create($request->all());

        return (new CategoryResource($category));
    }
677499
public function store()
    {
        $attributes = request()->validate(DocumentCategory::$rules, DocumentCategory::$messages);

        $category = $this->createEntry(DocumentCategory::class, $attributes);

        return redirect_to_resource();
    }
302546
public function actionCreate($slug, $category_id = null)
    {
        $model = $slug == Category::SLUG ? $this->getCategoryModel() : $this->getItemModel($category_id);
        $modelCategory = $this->getCategoryModel();
        $currentCategory = empty($category_id) ? null : $modelCategory::findOne(['id' => $category_id]);

        $this->scenarios($model);

        if ($model->load(Yii::$app->request->post())) {
            if(Yii::$app->request->isAjax){
                Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
                return ActiveForm::validate($model);
            }
            else{
                if(isset($_FILES)){
                    $this->saveFiles($model);
                }
                if($model->save()){
                    $this->trigger(self::EVENT_AFTER_SAVE, new EventController(['model' => $model]));
                    $this->flash('success', Yii::t('gr', 'Post created'));
                    return $this->redirect(Url::previous());
                }
                else{
                    $this->flash('error', Yii::t('gr', 'Error'));
                    return $this->refresh();
                }
            }
        }
        else {
            if($slug == Category::SLUG){
                $title = empty($currentCategory) ? Yii::t('gr', 'Create subcategory in the top-level category') : Yii::t('gr', 'Create Subcategory in Category <b>«{0}»</b>', [$currentCategory->title]);
            }else{
                $title = empty($currentCategory) ? Yii::t('gr', 'Create an item in the top-level category') : Yii::t('gr', 'Create Item in Category <b>«{0}»</b>', [$currentCategory->title]);
            }

            return $this->render('create', [
                'model' => $model,
                'currentCategory' => $currentCategory,
                'title' => $title
            ]);
        }
    }
317247
public function actionCreate()
    {
        $model = new Post();
        $model->load(Yii::$app->request->get());

        if ($model->load(Yii::$app->request->post()) && $model->save()) {
            Yii::$app->session->setFlash('postSaved');
            return $this->redirect(['update', 'id' => $model->id]);
        }

        if ($model->type->show_category) {
            $model->setScenario('required_category');
        }

        return $this->render('create', [
            'model' => $model,
        ]);
    }
187198
protected function generateCategoryUrl()
    {
        /** @var $target PageModel */
        if ($this->jumpTo && ($target = $this->objModel->getRelated('jumpTo')) instanceof PageModel) {
            $page = $target;
        } else {
            $page = $GLOBALS['objPage'];
        }

        $manager = System::getContainer()->get('codefog_news_categories.manager');

        /** @var NewsCategoryModel $category */
        $category = NewsCategoryModel::findPublishedByIdOrAlias(Input::get($manager->getParameterName()));

        // Generate the category URL
        if ($category !== null) {
            $url = $manager->generateUrl($category, $page);
        } else {
            // Generate the regular URL
            $url = $page->getFrontendUrl();
        }

        return $url;
    }
684024
public function actionCreate()
    {
        $model = new Article();
        if ($model->load(Yii::$app->request->post()) && $model->save()) {
            Yii::$app->getSession()->setFlash('success', Yii::t('article', 'Create success.'));
            return $this->redirect(['view', 'id' => $model->id]);
        }
        return $this->render('create', [
            'model' => $model,
        ]);
    }
936235
function createCategories() {
    $cnt = count( $this->categories );
    if( 0 >= $cnt )
      return;
    $output = null;
    foreach( $this->categories as $category ) {
      $attributes = $this->_createParams( $category['params'], array( 'LANGUAGE' ));
      if( is_array( $category['value'] )) {
        foreach( $category['value'] as $cix => $categoryPart )
          $category['value'][$cix] = $this->_strrep( $categoryPart );
        $content  = implode( ',', $category['value'] );
      }
      else
        $content  = $this->_strrep( $category['value'] );
      $output    .= $this->_createElement( 'CATEGORIES', $attributes, $content );
    }
    return $output;
  }