public function destroy($id) { $serie = GallerySerie::with('category')->where('id', '=', $id)->firstOrFail(); $path = public_path() . config('gallery.path') . $serie->category->slug . '/' . $serie->slug; $this->removeDirectory($path); $this->getById($id)->delete(); }
public function reposition() { if (\Request::has('item')) { $i = 0; foreach (\Request::get('item') as $id) { $i++; $item = GallerySerie::find($id); $item->position = $i; $item->save(); } return \Response::json(array('success' => true)); } else { return \Response::json(array('success' => false)); } }
public function destroy($id) { $image = $this->getById($id); $gallerySerie = GallerySerie::where('id', '=', $image->serie_id)->firstOrFail(); $galleryCategory = GalleryCategory::where('id', '=', $gallerySerie['category_id'])->firstOrFail(); $path = public_path() . config('gallery.path') . $galleryCategory['slug'] . '/' . $gallerySerie['slug']; $file = $path . '/' . $id . '.' . $image->extension; $thumb = $path . '/' . $id . '_thumb.' . $image->extension; if (is_file($file)) { unlink($file); } if (is_file($thumb)) { unlink($thumb); } $this->getById($id)->delete(); }
public function filter($gallerySerie_id) { $galleryImages = GalleryImage::where('serie_id', '=', $gallerySerie_id)->orderBy('position')->get(); $gallerySerie = GallerySerie::where('id', '=', $gallerySerie_id)->firstOrFail(); return view('gallery.images.index', compact('galleryImages', 'gallerySerie', 'gallerySerie_id')); }