public function recursos($id) { $imagenes = \App\elemento::where('tipo_elemento', '=', 1)->where('id_galeria', '=', $id)->get(); $videos = \App\elemento::where('tipo_elemento', '=', 2)->where('id_galeria', '=', $id)->get(); $galerias = \App\galeria::select('id_tipo_galeria as id')->get(); $datos = array(); foreach ($galerias as $val) { $datos[] = $val->id; } $data = array('categorias' => \DB::table('tipo_galeria')->select('id_tipo_galeria as id', 'nombre')->where('activo', '=', 1)->whereIn('tipo_galeria.id_tipo_galeria', $datos)->get(), 'videos' => $videos, 'imagenes' => $imagenes); // dd($data); return view('public/galerias', $data); }
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); }