aboutsummaryrefslogtreecommitdiffhomepage
path: root/app/Http
diff options
context:
space:
mode:
Diffstat (limited to 'app/Http')
-rw-r--r--app/Http/Controllers/UserController.php29
1 files changed, 29 insertions, 0 deletions
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 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use Illuminate\Http\Request;
+use Auth;
+
+class UserController extends Controller
+{
+ public function Profile()
+ {
+ $user = Auth::user();
+ return view('profile', compact('user', $user));
+ }
+
+ public function updateAvatar(Request $request)
+ {
+ $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.');
+ }
+}