public function postEliminarFoto(EliminarFotoRequest $request)
 {
     $foto = Foto::find($request->get('id'));
     $album_id = $foto->album_id;
     $rutaanterior = getcwd() . $foto->ruta;
     @unlink(realpath($rutaanterior));
     $foto->delete();
     return redirect("/validado/fotos?id={$foto->album_id}")->with('eliminado', 'Foto eliminada');
 }
 public function authorize()
 {
     $id = $this->get('id');
     $foto = Foto::find($id);
     $album = Album::find($foto->album_id);
     if ($foto) {
         return true;
     }
     return false;
 }
예제 #3
0
 /**
  * Determine if the user is authorized to make this request.
  *
  * @return bool
  */
 public function authorize()
 {
     $user = Auth::user();
     $id = $this->get('id');
     $foto = Foto::find($id);
     $album = $user->albumes()->find($foto->album_id);
     if ($album) {
         return true;
     }
     return false;
 }
 public function postActualizarFoto(ActualizarFotoRequest $request)
 {
     $foto = Foto::find($request->get('id'));
     $foto->nombre = $request->get('nombre');
     $foto->descripcion = $request->get('descripcion');
     if ($request->hasFile('imagen')) {
         $imagen = $request->file('imagen');
         $ruta = '/img/';
         $nombre = sha1(Carbon::now()) . '.' . $imagen->guessExtension();
         $imagen->move(getcwd() . $ruta, $nombre);
         $rutaAnterior = getcwd() . $foto->ruta;
         if (file_exists($rutaAnterior)) {
             unlink(realpath($rutaAnterior));
         }
         $foto->ruta = $ruta . $nombre;
     }
     $foto->save();
     return redirect('validado/albumes/admin-informes');
 }