From e7307d3241fb1f31a10ef92565c17b224d5983f0 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Sun, 1 Jul 2018 12:13:36 +0200 Subject: Added user avatars --- app/Http/Controllers/UserController.php | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 app/Http/Controllers/UserController.php (limited to 'app/Http') diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php new file mode 100644 index 0000000..1e2b204 --- /dev/null +++ b/app/Http/Controllers/UserController.php @@ -0,0 +1,29 @@ +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.'); + } +} -- cgit v1.2.3