/** * Creates a new Point model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Point(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }
/** * Creates a new Point model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionAddpoints($rule_id, $count = 1) { $maxpos = Point::find(['rule_id' => $rule_id])->max('position'); for ($i = 0; $i < $count; $i++) { $model = new Point(); $model->rule_id = intval($rule_id); $model->position = $maxpos + $i + 1; $model->points = 0; $model->save(); } return $this->redirect(['view', 'id' => $rule_id]); }