/** * @return string|\yii\web\Response */ public function run() { $model = new Empresas(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->controller->redirect(['detalle', 'id' => $model->id]); } else { return $this->controller->render('crear', ['model' => $model]); } }
/** * Crea una empresa * @return bool|Empresas */ private function crearEmpresa() { $this->nombre_franquicia = $this->nombre_empresa; $model = new Empresas(); $model->id_usuario = $this->id_usuario; $model->nombre = $this->nombre_empresa; $model->rnc = $this->rnc; $model->logo = $this->logo; $model->slogan = $this->slogan; $model->id_sector = $this->id_sector; $model->web = $this->web; $model->facebook = $this->facebook; $model->twitter = $this->twitter; $model->estado = Empresas::ESTADO_INACTIVO; if ($model->save()) { return $model; } return false; }