コード例 #1
0
 public function save($runValidation = true, $attributeNames = null)
 {
     if (parent::save($runValidation, $attributeNames)) {
         //dopo aver salvato le modifiche, processa gli upload delle foto
         foreach ($this->addimage as $tmpfoto) {
             $foto = new Foto();
             $foto->cartellone = $this->id;
             $foto->tmpname = $tmpfoto;
             $foto->save();
         }
         return true;
     }
     return false;
 }
コード例 #2
0
ファイル: SiteFotos.php プロジェクト: safaricco/admfw
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $idMidia = Midia::where('id_registro_tabela', $id)->where('id_tipo_midia', $this->tipo_midia)->first()->id_midia;
     $dados['imagens'] = Midia::find($idMidia)->multimidia()->where('id_midia', $idMidia)->get();
     $dados['dados'] = Foto::findOrFail($id);
     return view('foto', $dados);
 }
コード例 #3
0
ファイル: SiteGaleria.php プロジェクト: safaricco/admfw
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $idMidia = collect(Midia::where('id_registro_tabela', $id)->where('id_tipo_midia', $this->tipo_midia)->first())->first();
     if (!empty($idMidia)) {
         $dados['imagens'] = Midia::find($idMidia)->multimidia()->where('id_midia', $idMidia)->get();
     } else {
         $dados['imagens'] = '';
     }
     $dados['destacada'] = Midia::where('id_registro_tabela', $id)->where('id_tipo_midia', $this->tipo_midia)->first();
     $dados['galeria'] = Foto::findOrFail($id);
     return view('site/galeria-page', $dados);
 }
コード例 #4
0
 public function actionUpload()
 {
     $file = UploadedFile::getInstanceByName('userfile');
     \Yii::$app->response->format = Response::FORMAT_JSON;
     if ($file !== null) {
         $storePath = Foto::getTempPath();
         $filename = $file->getBaseName() . '_' . rand() . '.' . $file->getExtension();
         if ($file->saveAs($storePath . '/' . $filename)) {
             return ['tempFile' => $filename, 'success' => true];
         }
     }
     return ['success' => false];
 }
コード例 #5
0
ファイル: FotoSearch.php プロジェクト: AndersonCruz123/PAPS
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Foto::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['idFoto' => $this->idFoto, 'idOcorrencia' => $this->idOcorrencia, 'idDenuncia' => $this->idDenuncia]);
     $query->andFilterWhere(['like', 'comentario', $this->comentario])->andFilterWhere(['like', 'endereco', $this->endereco]);
     return $dataProvider;
 }
コード例 #6
0
ファイル: FotoSearch.php プロジェクト: knildark/ConejitoYii2
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Foto::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id_foto' => $this->id_foto]);
     $query->andFilterWhere(['like', 'titutlo', $this->titutlo])->andFilterWhere(['like', 'link', $this->link]);
     return $dataProvider;
 }
コード例 #7
0
 public function getFotoDenuncia($id)
 {
     $foto = Foto::findAll(['idDenuncia' => $id]);
     return $foto;
 }
コード例 #8
0
ファイル: Fotos.php プロジェクト: safaricco/admfw
 public function updateStatus($status, $id)
 {
     try {
         $dado = Foto::findOrFail($id);
         $dado->status = $status;
         $dado->save();
         session()->flash('flash_message', 'Status alterado com sucesso!');
     } catch (\Exception $e) {
         LogR::exception($dado, $e);
         session()->flash('flash_message', 'Ops!! Ocorreu algum problema!. ' . $e->getMessage());
     }
     return Redirect::back();
 }
コード例 #9
0
 /**
  * Finds the Foto model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Foto the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Foto::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
コード例 #10
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($album_id, $id)
 {
     //
     $foto = Foto::find($id);
     $checkfile = file_exists(public_path('upload/besar/' . $foto->foto_besar));
     $checkfile2 = file_exists(public_path('upload/kecil/' . $foto->foto_kecil));
     if ($checkfile) {
         unlink(public_path('upload/kecil/' . $foto->foto_kecil));
     }
     if ($checkfile2) {
         unlink(public_path('upload/besar/' . $foto->foto_besar));
     }
     if ($foto->delete()) {
         return response()->json(array('success' => TRUE));
     }
 }
コード例 #11
0
ファイル: Ocorrencia.php プロジェクト: AndersonCruz123/PAPS
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getFotos()
 {
     return $this->hasMany(Foto::className(), ['idOcorrencia' => 'idOcorrencia']);
 }
コード例 #12
0
 /**
  * Creates a new Denuncia model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Denuncia();
     $model->idLocal = 0;
     if ($model->load(Yii::$app->request->post())) {
         list($dia, $mes, $ano) = split('[/]', $model->data);
         $model->data = $ano . '-' . $mes . '-' . $dia;
         $model->imageFiles = UploadedFile::getInstances($model, 'imageFiles');
         $path = Yii::$app->basePath . '/web/uploadFoto/';
         $model->status = 1;
         if ($model->save()) {
             foreach ($model->imageFiles as $file) {
                 $foto = new Foto();
                 $foto->idDenuncia = $model->idDenuncia;
                 $foto->endereco = $path . $file->baseName . '.' . $file->extension;
                 $foto->nome = $file->baseName . '.' . $file->extension;
                 $foto->comentario = $model->comentarioFoto;
                 $file->saveAs($foto->endereco);
                 $foto->save();
                 $foto = null;
             }
             return $this->render('sucesso');
         } else {
             list($ano, $mes, $dia) = split('[-]', $model->data);
             $model->data = $dia . '/' . $mes . '/' . $ano;
             return $this->render('create', ['model' => $model]);
         }
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
コード例 #13
0
 public function foto($id)
 {
     $this->data['title'] = 'Album Foto';
     $album = Models\Foto::where('id_album', $id)->OrderBy('id_foto', 'desc')->paginate(12);
     $this->data['foto'] = $album;
     return view('bappeda.galeri_detail', $this->data);
 }
コード例 #14
0
public function getDelFoto($id){
Foto::destroy($id);
return redirect('home')->with('message','Фото удалено');

}
コード例 #15
0
 /**
  * Updates an existing Ocorrencia model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     if (strcmp($model->status, 'Aberto') == 0) {
         $model->status = 1;
     } elseif (strcmp($model->status, 'Solucionado') == 0) {
         $model->status = 2;
     } elseif (strcmp($model->status, 'Não Solucionado') == 0) {
         $model->status = 3;
     }
     $model->idNatureza = $model->idNaturezabkp;
     $model->idSubLocal = $model->idSubLocalbkp;
     $model->idCategoria = $model->idCategoriabkp;
     $model->cpfUsuario = Yii::$app->user->identity->cpf;
     $sublocal = Sublocal::findOne($model->idSubLocalbkp);
     $model->idLocal = $sublocal->idLocalbkp;
     if ($model->load(Yii::$app->request->post())) {
         $model->imageFiles = UploadedFile::getInstances($model, 'imageFiles');
         $path = Yii::$app->basePath . '/web/uploadFoto/';
         list($dia, $mes, $ano) = split('[/]', $model->data);
         $model->data = $ano . '-' . $mes . '-' . $dia;
         if ($model->dataConclusao != null) {
             list($dia, $mes, $ano) = split('[/]', $model->dataConclusao);
             $model->dataConclusao = $ano . '-' . $mes . '-' . $dia;
         }
         if ($model->save()) {
             //     	if (count ($model->imageFiles) >= 1) {
             if ($model->comentarioFoto != null) {
                 $foto = FotoController::getFotoOcorrencia($model->idOcorrencia);
                 foreach ($foto as $file) {
                     $file->comentario = $model->comentarioFoto;
                     $file->save();
                 }
             }
             foreach ($model->imageFiles as $file) {
                 $foto = new Foto();
                 $foto->idOcorrencia = $model->idOcorrencia;
                 $foto->comentario = $model->comentarioFoto;
                 $foto->endereco = $path . $file->baseName . '.' . $file->extension;
                 $foto->nome = $file->baseName . '.' . $file->extension;
                 $file->saveAs($foto->endereco);
                 $foto->save();
                 $foto = null;
             }
             //             }
             return $this->redirect(['view', 'id' => $model->idOcorrencia]);
         } else {
             list($ano, $mes, $dia) = split('[-]', $model->data);
             $model->data = $dia . '/' . $mes . '/' . $ano;
             if ($model->dataConclusao != null) {
                 list($ano, $mes, $dia) = split('[-]', $model->dataConclusao);
                 $model->dataConclusao = $dia . '/' . $mes . '/' . $ano;
             }
             return $this->render('update', ['model' => $model]);
             //  echo "error da foto em".$image->error;
         }
     } else {
         return $this->render('update', ['model' => $model]);
     }
 }