I'm learning to create some forum, but when I update a photo profile, it can't show. When I try to inspect element it says:
"Failed to load resource: the server responded with a status of 404 (Not Found)"
This is my Controller:
public function update()
{
$avatar = request()->file('avatar');
$avatar_validate = 'image|mimes:jpeg,png,jpg,svg|max:2048';
request()->validate([
'username' => 'required|alpha_num|min:6|max:20|unique:users,username,' . auth()->id(),
'name' => 'string|required',
'avatar' => $avatar ? $avatar_validate : "",
]);
$hash = auth()->user()->hash;
$avatar_name = $avatar->storeAs('profile-picture', "{$hash}.{$avatar->extension()}");
auth()->user()->update([
'username' => request('username'),
'name' => request('name'),
'avatar' => $avatar_name,
]);
return redirect()->route('users.show', auth()->user()->usernameOrHash());
}