예제 #1
0
 /**
  * Creates a new Empleado model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Empresas();
     if ($model->load(Yii::$app->request->post())) {
         $model->fechaCreacion = date("d-m-Y");
         $model->save();
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
 /**
  * Creates a new Empresas model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Empresas();
     if ($model->load(Yii::$app->request->post())) {
         $model->arquivo = UploadedFile::getInstance($model, 'arquivo');
         if ($model->arquivo) {
             $nomeImagem = '/imgs/logos-empresas/' . $model->id . '.' . $model->arquivo->getExtension();
             $model->logomarca = $nomeImagem;
             $model->arquivo->saveAs(Yii::getAlias('@webroot') . $nomeImagem);
         }
         if ($model->save()) {
             return $this->redirect(['view', 'id' => $model->id]);
         }
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }