Today, We want to share with you validation Update User Profile in Laravel 5.7.In this post we will show you Update User Profile Laravel 5.7, hear for Edit user profile best practice in laravel 5.7 we will give you demo and example for implement.In this post, we will learn about How to upload profile picture Avatar in Laravel 5.7 Authentication with an example.
validation Update User Profile in Laravel 5.7
Contents
There are the Following The simple About validation Update User Profile in Laravel 5.7 Full Information With Example and source code.
As I will cover this Post with live Working example to develop Update Laravel 5.7 User Profiles, so the laravel 5.7 update user profile for this example is following below.
Upload profile picture Avatar in Laravel 5.7 Authentication
public function update(Request $request) { $user = Auth::user(); $this->validate($request,[ 'name' => 'required|max:255', 'email' => 'required|email|max:255|unique:users,id,'.$user->id, ]); $user->name = $request->name; $user->email = $request->email; if($request->password){ $this->validate($request,[ 'password' => 'min:6|confirmed', ]); $user->password = bcrypt($request->password); } if($request->hasFile('profileImg')){ $this->validate($request,[ 'profileImg' => 'mimes:png', ]); $profileImg = $request->file('profileImg'); $uploadProfilename = time() . '.' . $profileImg->getClientOriginalExtension(); Image::make($profileImg)->resize(300, 300)->save( public_path('/uploads/uploads/' . $uploadProfilename ) ); $user->profileImg = $uploadProfilename; } $user->save(); return view('home.profile', array('user' => Auth::user())); }
Handle Profile Picture Upload Request
public function update(Request $request){ $request->validate([ 'profile' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048', ]); $user = Auth::user(); $profileName = $user->id.'_avatar'.time().'.'.request()->profile->getClientOriginalExtension(); $request->profile->storeAs('avatars',$profileName); $user->profile = $profileName; $user->save(); return back() ->with('success','You have successfully upload image.'); }
Angular 6 CRUD Operations Application Tutorials
Read :
Summary
You can also read about AngularJS, ASP.NET, VueJs, PHP.
I hope you get an idea about validation Update User Profile in Laravel 5.7.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, donβt forget to share.
I am Jaydeep Gondaliya , a software engineer, the founder and the person running Pakainfo. I’m a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, JavaScript, jQuery, Laravel, CodeIgniter, VueJS, AngularJS and Bootstrap from the early stage.