*/ protected $fillable = [ 'name', 'email', 'password', 'username', 'is_active' ]; /** * The attributes that should be hidden for serialization. * * @var array */ protected $hidden = [ 'password', 'remember_token', ]; /** * The attributes that should be cast. * * @var array */ protected $casts = [ 'email_verified_at' => 'datetime', 'password' => 'hashed', ]; public function changePassword(Request $request) { $request->validate([ 'newPassword' => 'required|string|min:8', 'confirmNewPassword' => 'required|string|min:8', ]); if($request->newPassword != $request->confirmNewPassword) { throw new \Exception("New Password & Confirm New Pasword are not same"); } $this->password = Hash::make($request->newPassword); $this->save(); } }