Level 17
Auth::user()->update([
'avatar' => $request->input('avatar'),
]);
You don't need that, however you need to call $user->save() at the end of your if statement
1 like
public function index(){
return view ('profile.editavatar');
}
public function store(Request $request){
$this->validate($request, [
'avatar' => 'max:255',
]);
Auth::user()->update([
'avatar' => $request->input('avatar'),
]);
if($request->hasFile('avatar')){
$user = Auth::user();
$image = $request->file('avatar');
$filename = time() . '.' . $image->getClientOriginalExtension();
// $path = storage_path('/uploads/avatars/'. $user->username . $filename );
// Storage::makeDirectory($path, 0777, true);
$location = public_path('uploads/avatars/'. $filename);
Image::make($image)->resize(300,300)->save($location);
$user->avatar = $filename;
}
}
There is some struggle with the $user variable, as I am editing the profile content with 2 Controllers. On for written content within the profile & one for Avatar Upload. This is the UploadController.
Any suggestions?
Auth::user()->update([
'avatar' => $request->input('avatar'),
]);
You don't need that, however you need to call $user->save() at the end of your if statement
Please or to participate in this conversation.