I have store()
in controller, and in this place I call 3 functions. Variable $users
store correct fields validation with values them. In next step I call function which hash password. At the end I call function which add user to database. My problem is that hash password is not add to database.What can I do that pass hashPassword to createUser()
?
public function store(RegistrationRequest $request, UserService $user)
{
$user = $request->correctValidate();
$userService->hashPassword($user['password']);
$userService->createUser($user);
}
public function createUser($request): void
{
User::create($request);
}
public function hashPassword($request)
{
return Hash::make($request);
}
public function correctValidate()
{
return $this->validated();
}
@Deks2 Please try below solution:
$user['password'] = $userService->hashPassword($user['password']);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.