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 run()
 {
     DB::statement('SET FOREIGN_KEY_CHECKS = 0');
     Foto::truncate();
     Album::truncate();
     Usuario::truncate();
     $this->call('UsuariosSeeder');
     //$this->call('AlbumesSeeder');
     //$this->call('FotosSeeder');
 }
 public function authorize()
 {
     $id = $this->get('id');
     $foto = Foto::find($id);
     $album = Album::find($foto->album_id);
     if ($foto) {
         return true;
     }
     return false;
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $albumes = Album::all();
     foreach ($albumes as $album) {
         $cantidad = rand(0, 15);
         for ($i = 0; $i < $cantidad; $i++) {
             Foto::create(['nombre' => "foto{$i}", 'descripcion' => "descripcion{$i}", 'ruta' => "/img/test{$i}.jpg", 'album_id' => $album->id]);
         }
     }
 }
 /**
  * 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;
 }
Beispiel #6
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $albumes = Album::all();
     $contador = 0;
     foreach ($albumes as $album) {
         $cantidad = mt_rand(0, 5);
         for ($i = 0; $i < $cantidad; $i++) {
             $contador++;
             Foto::create(['nombre' => "Nombre foto{$contador}", 'descripcion' => "Descripcion foto {$contador}", 'ruta' => '/img/text.png', 'album_id' => $album->id]);
         }
     }
 }
 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');
 }