blob: 42f4e16cc673aee67a55d1559e45d70457716520 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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 uploaded the avatar.');
}
}
|