Esempio n. 1
0
 public function destroy(Request $request)
 {
     $id = $request->id;
     $imagenes = \App\elemento::where('tipo_elemento', '=', 1)->where('id_galeria', '=', $id)->get();
     $portada = \App\galeria::find($id);
     $portada = $portada->portada;
     if (\DB::statement('CALL del_galeria(' . $id . ')')) {
         foreach ($imagenes as $val) {
             if (file_exists(getcwd() . $val->url)) {
                 echo getcwd() . $val->url;
                 unlink(getcwd() . $val->url);
             }
         }
     }
     if (file_exists(getcwd() . $portada)) {
         unlink(getcwd() . $portada);
     }
     $portada = explode("/", $portada);
     array_pop($portada);
     $portada = implode("/", $portada);
     rmdir(getcwd() . $portada);
 }