Lumen 7.0 版本 "Call to a member function hash_password() on null"

Lumen 7.0 version "Call to a member function hash_password() on null"

hash_password 函数未调用(UService 中的任何其他函数 class)

这个“UService.php”文件包括App\Http\Services\UService.php

这是我称之为“hash_password 函数”的控制器,错误生成行带有下划线

显示错误的第三张图片即将到来。我是 lumen 框架的新手。

修改您的register方法如下;

public function register(UserRegisterRequest $request, UService $uService, User $user) {
    $password_hash = $uService->hash_password($request->password);
    $user->createUser($request, $password_hash);
    $success_message = "registration completed success";
    return $uService->is200Response($success_message);
}