Creates a new Rating model.
If creation is successful, the browser will be redirected to the 'view' page.
@return mixed
965137
public function actionVote()
    {
        $star_rating_module = Yii::$app->getModule('star-rating');
        $response = [
            'status' => 500,
            'message' => $star_rating_module::t('Server problem')
        ];

        try
        {
            $cookies = Yii::$app->request->cookies;
            if(Yii::$app->user->isGuest)
            {
                if (!$cookies || !$cookies->getValue('visitor'))
                {
                    $cookies = Yii::$app->response->cookies;
                    $cookies->add(new Cookie([
                        'name' => 'visitor',
                        'value' => md5(time() . rand(1, 100)),
                        'expire' => (time() + (3600)),
                    ]));
                }
            }
            $item_id = isset($_POST['item_id']) ? $_POST['item_id'] : 0;
            $service_id = isset($_POST['service_id']) ? $_POST['service_id'] : 0;
            $rating = isset($_POST['rating']) ? $_POST['rating'] : 0;
            $user_id = Yii::$app->user->isGuest ? 0 : (int) Yii::$app->user->id;
            $ip = Yii::$app->request->userIP;
            $visitor_cookie = $cookies->getValue('visitor');

            if(Yii::$app->user->isGuest)
            {
                $rate = Rating::find()
                    ->where(['item_id' => $item_id, 'service_id' => $service_id, 'cookie' => $visitor_cookie])
                    ->one();
            }
            else
            {
                $rate = Rating::find()
                    ->where(['item_id' => $item_id, 'service_id' => $service_id, 'user_id' => $user_id ])
                    ->one();
            }


            if(!$rate)
            {
                $model = new Rating();
                $model->service_id = $service_id;
                $model->item_id = $item_id;
                $model->user_id = $user_id;
                $model->rating = $rating;
                $model->ip = $ip;
                $model->cookie = $visitor_cookie;

                if($model->save())
                    $response = [
                        'status' => 200,
                        'message' => $star_rating_module::t('Successful')
                    ];
                else
                    $response = [
                        'status' => 400,
                        'message' => $star_rating_module::t('Failed to save')
                    ];
            }
            else
            {
                $rate->rating = $rating;
                if ($rate->save())
                    $response = [
                        'status' => 200,
                        'message' => $star_rating_module::t('Changed vote')
                    ];
                else
                    $response = [
                        'status' => 400,
                        'message' => $star_rating_module::t('Failed to save')
                    ];
            }
        }
        catch(Exception $exp)
        {
            $response = [
                'status' => 500,
                'message' => $star_rating_module::t('Server problem')
            ];
        }
        return json_encode($response);
    }
259008
public function actionCreate()
    {
        /* @var $model ActiveRecord */
        $model = $this->createModel();
        $this->beginTransaction();
        try {
            $this->fire('beforeCreate', [$model]);
            $model->load(Yii::$app->request->post(), '');
            $this->fire('create', [$model]);
            if ($model->save()) {
                $this->fire('created', [$model]);
                $this->commit();
                $model->refresh();
            } else {
                $this->fire('rollbackCreate', [$model]);
                $this->rollBack();
            }
        } catch (\Exception $e) {
            $this->fire('errorCreate', [$model, $e]);
            $this->rollBack();
            throw $e;
        }

        return $model;
    }
522487
public function actionCreate()
    {
        $model = Yii::createObject($this->modelClass);

        if ($model->load(Yii::$app->request->post()) && $model->save()) {
            Yii::$app->session->setFlash('success', Yii::t('yii2mod.cms', 'Page has been created.'));

            return $this->redirect(['index']);
        }

        return $this->render($this->createView, [
            'model' => $model,
        ]);
    }
1111494
public function refreshRatingAction()
    {
        $model = new ViewModel();
        $model->setTemplate('applications/manage/_rating');
        
        $application = $this->repositories->get('Applications/Application')
                        ->find($this->params('id', 0));
        
        if (!$application) {
            throw new \DomainException('Invalid application id.');
        }
        
        $model->setVariable('application', $application);
        return $model;
    }
852656
public function actionCreate() {
    $form = new RoleForm();
    $form->isNewRecord = true;
    $form->auth = Yii::$app->authManager;

    if ($form->load(Yii::$app->request->post()) && $form->save()) {
      Yii::$app->session->setFlash('success', 'Роль создана');
      return $this->redirect(['view', 'id' => $form->name]);
    } else {
      return $this->render('create', [
        'form' => $form,
      ]);
    }


  }
888223
public function created(RatingModelContract $rating)
    {
        event(new ModelWasRated($rating->rateable, $rating->user_id));
        app(RatingServiceContract::class)->updateRating($rating->rateable, $rating->rating);
    }
1077236
protected function createModel()
    {
        if (! $this->model instanceof LogModel) {
            $this->model = $this->loader->getModels()->createLogModel();
            $this->model->applyBrowseSettings();
        }

        return $this->model;
    }
471623
public function actionCreate()
    {
        $model = new SeoPresets();
        $model->loadDefaultValues();
        if ($model->load(Yii::$app->request->post()) && $model->save()) {
            if(Yii::$app->request->post('action') === 'apply') {
                return $this->redirect(['update', 'id' => $model->id]);
            }else{
                return $this->redirect(['view', 'id' => $model->id]);
            }
        }

        return $this->render('create', [
            'model' => $model,
        ]);
    }
1372902
public function create()
    {
        $record = $this->getNewModelInstance();

        $fields = array_only(
            $this->modelInformation->form->fields,
            $this->getRelevantFormFieldKeys(true)
        );

        $this->checkListParents(false);

        $values = $this->getFormFieldValuesFromModel($record, array_keys($fields));
        $errors = $this->getNormalizedFormFieldErrors();

        $renderedFields = $this->renderedFormFieldStrategies($record, $fields, $values, $errors);

        return view($this->getCreateView(), [
            'moduleKey'           => $this->moduleKey,
            'routePrefix'         => $this->routePrefix,
            'permissionPrefix'    => $this->permissionPrefix,
            'model'               => $this->modelInformation,
            'record'              => $record,
            'recordReference'     => null,
            'creating'            => true,
            'fields'              => $fields,
            'fieldStrategies'     => $renderedFields,
            'values'              => $values,
            'fieldErrors'         => $errors,
            'activeTab'           => $this->getActiveTab(),
            'errorsPerTab'        => $this->getErrorCountsPerTabPane(),
            'hasActiveListParent' => (bool) $this->listParentRelation,
            'topListParentOnly'   => $this->showsTopParentsOnly(),
            'listParents'         => $this->listParents,
        ]);
    }
417335
public function actionCreate()
    {
        $model = new Article();
        if ($model->load(Yii::$app->request->post()) && $model->save()) {
            return $this->redirect(['view', 'uuid' => $model->uuid]);
        } else {
            return $this->render('create', [
                'model' => $model,
            ]);
        }
    }
14003
public function actionCreate()
    {
        $model = new Client();
        if (Yii::$app->request->isAjax && $model->load(Yii::$app->request->post())) {
            Yii::$app->response->format = Response::FORMAT_JSON;
            return ActiveForm::validate($model);
        } else if ($model->load(Yii::$app->request->post()) && $model->save()) {
            Yii::$app->getSession()->setFlash('success', Yii::t('oauth2', 'Successful operation'));
            return $this->redirect(['view', 'id' => $model->client_id]);
        } else {
            return $this->render('create', [
                'model' => $model,
            ]);
        }
    }
386603
public function createAction()
    {
        // Load form
        $entityClass = $this->getModuleNamespace() . '\Entity\\' . $this->getEntityName();
        $entity      = new $entityClass();
        $form        = $this->getForm('Create' . $this->getEntityName());
        $form->bind($entity);

        // Implement Post/Redirect/Get pattern
        $prg = $this->prg();
        if ($prg instanceof Response) {
            return $prg;
        } else if (false !== $prg) {

            // Set form data
            $form->setData($prg);

            // Create account
            $result = $this->getService()->create();
            if ($result) {
                return $this->redirect()->toRoute($this->indexRoute);
            }
        }

        // Set up view model
        $viewModel = new ViewModel(array(
            'entityName' => $this->getEntityName(),
            'form'       => $form,
        ));
        $viewModel->setTemplate('infinity-base/crud/create');

        return $viewModel;
    }
595848
public function actionCreate()
    {
        if ((Authentication::findOne(['user_id' => Yii::$app->user->id])) != null || Authentication::isAuthentication(Yii::$app->user->id)) {
            return $this->redirect(['index']);
        }
        $model = new Authentication();
        $model->scenario = Authentication::SCENARIO_CREATE;
        if ($model->load(Yii::$app->request->post()) && $model->save()) {
            return $this->redirect(['index']);
        }
        return $this->render('create', [
            'model' => $model,
        ]);
    }
113212
public function actionCreate()
    {
        $model = new UserAuthItem(null);
        $model->type = $this->type;
        if ($model->load(Yii::$app->getRequest()->post()) && $model->save()) {
            Yii::$app->getSession()->setFlash('success', Yii::t('yuncms','Create success.'));
            return $this->redirect(['view', 'id' => $model->name]);
        } else {
            return $this->render('create', ['model' => $model]);
        }
    }
708626
public function actionNewCategory()
    {
        $model = new Category();
        $model->visible = 1;
        $model->sort = 0;
        if ($model->load(Yii::$app->request->post()) && $model->save()) {
            Log::info('Category added', $model->id, __METHOD__);
            $this->success(Yii::t('podium/flash', 'New category has been created.'));
            return $this->redirect(['admin/categories']);
        }
        return $this->render('category', [
            'model' => $model,
            'categories' => Category::find()->orderBy(['sort' => SORT_ASC, 'id' => SORT_ASC])->all()
        ]);
    }
1167264
public function createAction()
    {
        $form = $this->getServiceLocator()->get('playgroundreward_leaderboard_form');
        
        $request = $this->getRequest();
        $leaderboardType = new LeaderBoardType();
        
        if ($request->isPost()) {
            $data = array_merge(
                $request->getPost()->toArray(),
                $request->getFiles()->toArray()
            );

            $leaderboard = $this->getLeaderboardTypeService()->create($data, 'playgroundreward_leaderboard_form');
            if ($leaderboard) {
                $this->flashMessenger()->addMessage('The leaderboard "'.$leaderboard->getName().'" has been created');

                return $this->redirect()->toRoute('admin/leaderboardtype/list');
            } else {
                $this->flashMessenger()->addMessage('The leaderboard was not created');

                return $this->redirect()->toRoute('admin/leaderboardtype/list');
            }
        }

        $viewModel = new ViewModel();
        $viewModel->setTemplate('playground-reward/leader-board-type/leaderboardtype');

        return $viewModel->setVariables(array('form' => $form));
    }
392253
public function actionCreate()
    {
        $model = new \yongtiger\admin\models\Log();

        if ($model->load(Yii::$app->request->post()) && $model->save()) {
            Yii::$app->session->setFlash('success', Module::t('message', 'Successfully created.'));
            return $this->redirect(['view', 'id' => $model->id]);
        } else {
            return $this->render('create', [
                'model' => $model,
            ]);
        }
    }