From aa73af3be51f6e36ea9ea5a1f78ac18c0b2a352c Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Sun, 1 Jul 2018 12:45:00 +0200 Subject: Better avatar requests --- app/Http/Controllers/ImageController.php | 28 ++++++++++++++++++++++++++++ app/Http/Controllers/UserController.php | 2 +- 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 app/Http/Controllers/ImageController.php (limited to 'app/Http') diff --git a/app/Http/Controllers/ImageController.php b/app/Http/Controllers/ImageController.php new file mode 100644 index 0000000..37874f5 --- /dev/null +++ b/app/Http/Controllers/ImageController.php @@ -0,0 +1,28 @@ +avatar; + $storagePath = storage_path('app/public/avatars/' . $usersAvatar); + return Image::make($storagePath)->resize(100, 100)->response(); + + // $request->validate([ + // 'avatar' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048', + // ]); + // $user = Auth::user(); + // $avatarName = $user->id . '_avatar_' . time() . '.' . request()->avatar->getClientOriginalExtension(); + // $request->avatar->storeAs('avatars', $avatarName); + // $user->avatar = $avatarName; + // $user->save(); + // return back() + // ->with('success', 'You have successfully upload image.'); + } +} diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index 1e2b204..42f4e16 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -24,6 +24,6 @@ class UserController extends Controller $user->avatar = $avatarName; $user->save(); return back() - ->with('success', 'You have successfully upload image.'); + ->with('success', 'You have successfully uploaded the avatar.'); } } -- cgit v1.2.3