/** * Creates a new Productos model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Productos(); $fotos = new UploadForm(); if ($model->load(Yii::$app->request->post()) && $model->save()) { $request = Yii::$app->request; $fotos->imageFiles = UploadedFile::getInstances($fotos, 'imageFiles'); if ($fotos->upload($model->id)) { // file is uploaded successfully } if ($model->tipo == 0) { return $this->redirect(['view', 'id' => $model->id]); } else { if ($model->tipo == 1) { $porTiempo = new Temporales(); $porTiempo->fecha = $request->post('fecha'); $porTiempo->idproducto = $model->id; $porTiempo->save(); return $this->redirect(['view', 'id' => $model->id]); } else { $stock = new Stock(); $cantidad = $request->post('cant'); $stock->stock = $cantidad; $stock->idproducto = $model->id; $stock->save(); return $this->redirect(['view', 'id' => $model->id]); } } } else { $img_model = new UploadForm(); $searchModel = new CategoriasSearch(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); return $this->render('create', ['model' => $model, 'categorias' => $dataProvider, 'img_model' => $img_model]); } }
/** * Creates a new Productos model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Productos(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }