Answer the question
In order to leave comments, you need to log in
How to display avatar from Storage laravel?
Hello.
In the Profile Controller, when updating the profile, I write the avatar to Storeg:
/**
* Update user profile
*
* @param \App\User $user
* @param \App\Http\Requests\ProfileUserUpdateRequest $request
* @return \Illuminate\Http\RedirectResponse
*/
public function update(User $user, UserUpdate $request)
{
if($request->hasFile('avatar'))
{
// Get user avatar image request
$image = $request->file('avatar');
$extension = $image->getClientOriginalExtension();
// Resize image user avatar
$size = \Config::get('image.avatar_size');
$avatar = Image::make($image)->fit($size)->encode($extension);
// Save user avatar image
$path = $user->username . '/avatar.' . $extension;
Storage::disk('users')->put($path, $avatar);
}
$user->update($request->all());
return redirect()->route('profile.edit', $request['username']);
}
Answer the question
In order to leave comments, you need to log in
About flash - check for changes. And if something has changed, then do it There is a getOriginalredirect()->with('success', '...')
model method
Try it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question