aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorMateja <mail@matejamaric.com>2020-11-07 01:02:57 +0100
committerMateja <mail@matejamaric.com>2020-11-07 01:02:57 +0100
commitd64ceaaa73f9053a4787853a7c06758f6af53d65 (patch)
treee44a6390748410c00b3cb18502780e5ad178af15 /app
parent76cbb07c91ec5a868956c116d4fccc6e3cf8d487 (diff)
downloadyota-laravel-d64ceaaa73f9053a4787853a7c06758f6af53d65.tar.gz
yota-laravel-d64ceaaa73f9053a4787853a7c06758f6af53d65.zip
Gallery finished...
Diffstat (limited to 'app')
-rw-r--r--app/Http/Controllers/GalleryController.php8
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.');
}
}