/**
  * @throws \yii\db\StaleObjectException
  * @throws \yii\web\BadRequestHttpException
  * @throws \yii\web\NotFoundHttpException
  */
 public function run()
 {
     $model = $this->loadModel(\Yii::$app->request->get());
     $this->ensureAccess(['model' => $model]);
     if ($model->delete() === false) {
         throw new ServerErrorHttpException('Failed to delete the object for unknown reason.');
     }
     $redirectUrl = RedirectTo::build($this->redirectTo, $model);
     return $this->controller->redirect($redirectUrl);
 }
 /**
  * @throws \yii\web\BadRequestHttpException
  * @throws \yii\web\NotFoundHttpException
  */
 public function run()
 {
     $model = $this->loadModel(\Yii::$app->request->get());
     $model->scenario = $this->scenario;
     $this->ensureAccess(['model' => $model]);
     if ($model->load(\Yii::$app->request->post()) && $model->save()) {
         $redirectUrl = RedirectTo::build($this->redirectTo, $model);
         return $this->controller->redirect($redirectUrl);
     }
     return $this->controller->render($this->viewName, ['model' => $model]);
 }
 /**
  * @throws \yii\web\ForbiddenHttpException
  */
 public function run()
 {
     $this->ensureAccess();
     /** @var BaseActiveRecord $model */
     $model = new $this->modelClass(['scenario' => $this->scenario]);
     if ($model->load(\Yii::$app->request->post()) && $model->save()) {
         $redirectUrl = RedirectTo::build($this->redirectTo, $model);
         return $this->controller->redirect($redirectUrl);
     }
     return $this->controller->render($this->viewName, ['model' => $model]);
 }