Search code examples
laravelapiclasslumen

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


hash_password function not call (any other functions inside UService class)

this "UService.php" file include App\Http\Services\UService.php

this is the controller i called this "hash_password function" and error generating line is underlined

3rd image showing error is coming. I'm new to lumen framework.

enter image description here


Solution

  • Modify your register method as follows;

    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);
    }