/**
  * Creates a new Product model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Product();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->productID]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
 /**
  * Creates a new Product model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Product();
     if ($model->load(Yii::$app->request->post())) {
         $model->imageFile = UploadedFile::getInstance($model, 'imageFile');
         $imageName = 'uploadImage/' . $model->imageFile->getBaseName() . '.' . $model->imageFile->getExtension();
         $model->image_url = $imageName;
         if ($model->save()) {
             if ($model->upload()) {
             }
             return $this->redirect(['view', 'id' => $model->id]);
         }
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
 /**
  * Creates a new Product model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Product();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         //gets the instance of the uploaded file
         $ImageName = $model->name;
         $model->file = UploadedFile::getInstance($model, 'file');
         $model->file->saveAs('uploads/' . $ImageName . '.' . $model->file->extension);
         //saves db column path
         $model->logo = 'uploads/' . $ImageName . '.' . $model->file->extension;
         $model->save();
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }