/** * 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]); } }
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; }
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; } }