/** * Creates a new AliasUrl model. * If creation is successful, the browser will be redirected to the 'view' page. * * @return mixed */ public function actionCreate() { $model = new AliasUrl(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['index']); } else { return $this->render('create', ['model' => $model]); } }
/** * @param $public * @param $private * @param int $is_frontend * @return array|AliasUrl|mixed|null|\yii\db\ActiveRecord */ public static function addAliasByPrivate($public, $private, $is_frontend = 1) { /** @var $model \c006\url\models\AliasUrl */ $model = AliasUrl::find()->where(['private' => $private])->one(); if (is_object($model)) { $model->public = $public; if ($model->validate() && $model->save()) { return $model; } else { print_r($model->getErrors()); exit; } } $model = new AliasUrl(); $model->public = $public; $model->private = $private; $model->is_frontend = $is_frontend; if ($model->isNewRecord && $model->validate() && $model->save()) { return $model; } }