From e4fec1b5386c19a7c0bfb28b850862159c8710dd Mon Sep 17 00:00:00 2001 From: Mateja Date: Sat, 7 Nov 2020 00:10:15 +0100 Subject: Work on gallery... --- app/Http/Controllers/GalleryController.php | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/Http/Controllers/GalleryController.php b/app/Http/Controllers/GalleryController.php index 8f42b48..3f11997 100644 --- a/app/Http/Controllers/GalleryController.php +++ b/app/Http/Controllers/GalleryController.php @@ -4,6 +4,13 @@ namespace App\Http\Controllers; use Illuminate\Http\Request; +use dd; + +use Illuminate\Support\Facades\Redirect; +use Illuminate\Support\Facades\Validator; + +use App\Models\Image; + class GalleryController extends Controller { /** @@ -34,7 +41,21 @@ class GalleryController extends Controller */ public function store(Request $request) { - // + $validatedData = $request->validate([ + 'images' => 'required' + ]); + $images = $request->file('images'); + foreach ($images as $image) { + $save = new Image(); + $save->path = 'imgs/'; + $save->name = time() . '.' . $image->getClientOriginalExtension(); + + $image->storeAs($save->path, $save->name); + + $save->save(); + } + + return Redirect::back(); } /** @@ -79,6 +100,6 @@ class GalleryController extends Controller */ public function destroy($id) { - // + return Redirect::back(); } } -- cgit v1.2.3