diff options
Diffstat (limited to 'app/Http/Controllers/GalleryController.php')
-rw-r--r-- | app/Http/Controllers/GalleryController.php | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/app/Http/Controllers/GalleryController.php b/app/Http/Controllers/GalleryController.php index db0f956..064be02 100644 --- a/app/Http/Controllers/GalleryController.php +++ b/app/Http/Controllers/GalleryController.php @@ -20,7 +20,8 @@ class GalleryController extends Controller */ public function index() { - return view('pages.gallery'); + $images = Image::paginate(9); + return view('pages.gallery', compact('images')); } /** @@ -47,7 +48,7 @@ class GalleryController extends Controller $images = $request->file('images'); foreach ($images as $image) { $path = 'imgs/'; - $name = time() . '.' . $image->getClientOriginalExtension(); + $name = time() . '.' . uniqid() . '.' . $image->getClientOriginalExtension(); $image->move($path, $name); $save = new Image(); @@ -101,6 +102,7 @@ class GalleryController extends Controller */ public function destroy($id) { - return Redirect::back(); + Image::findOrFail($id)->delete(); + return Redirect::back()->with('status', 'Image deleted.'); } } |