/**
  * Creates a new Usuarios model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Usuarios();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
示例#2
0
 /**
  * Creates a new Usuarios model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Usuarios();
     $model->scenario = 'create';
     if ($model->load(Yii::$app->request->post())) {
         // process uploaded image file instance
         $image = $model->uploadImage();
         $model->criado_por = Yii::$app->user->getId();
         if ($model->save()) {
             // upload only if valid uploaded file instance found
             if ($image !== false) {
                 $path = $model->getImageFile();
                 $image->saveAs($path);
             }
             return $this->redirect(['view', 'id' => $model->id_usuario]);
         }
         //error saving model
         return $this->render('create', ['model' => $model]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }