Esempio n. 1
0
 /**
  * Creates a new Fotos model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Fotos();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
Esempio n. 2
0
 public function add()
 {
     $fotos = new Fotos();
     $fotos->namefoto = $this->name;
     $fotos->deskfoto = $this->desk;
     $fotos->id_album = $this->id_album;
     $fotos->foto_path = $this->foto_path;
     $fotos->save();
     return $fotos;
 }
Esempio n. 3
0
 public function upload($id)
 {
     if ($this->validate()) {
         foreach ($this->imageFiles as $file) {
             $file_name = date('Y-m-d H:i:s') . "_" . $file->baseName . '.' . $file->extension;
             $file->saveAs('assets/imgOfertas/' . $file_name);
             $foto = new Fotos();
             $foto->idProducto = $id;
             $foto->url = $file_name;
             $foto->save();
         }
         return true;
     } else {
         return false;
     }
 }