app/Http/Controllers/RegisterController.php
/**
     * Creates a new user
     *
     * @param RegisterUserRequest $request
     * @param UserRepository $userRepository
     *
     * @return JsonResponse
     */
Creates a new user
@param RegisterUserRequest $request
@param UserRepository $userRepository


Creates a new user @param RegisterUserRequest $request @param UserRepository $userRepository
public function store(
        TokenService $tokenService,
        RegisterUserRequest $request,
        UserRepository $userRepository
    ) {
        $user = $userRepository->create($request->only([
            'username',
            'password'
        ]));
        $data = array_merge(
            ['data' => [
            'id' => $user->id,
            'username' => $user->username,
        ]],
            $tokenService->createToken($user->username, $request->password)
        );
        return \response()->json($data);
    }
public function store ( TokenService $ tokenService , RegisterUserRequest $ request , UserRepository $ userRepository ) { $ user = $ userRepository -> create ( $ request -> only ( [ 'username' , 'password' ] ) ) ; $ data = array_merge ( [ 'data' => [ 'id' => $ user -> id , 'username' => $ user -> username , ] ] , $ tokenService -> createToken ( $ user -> username , $ request -> password ) ) ; return \ response ( ) -> json ( $ data ) ; }
Creates a new user
 @param RegisterUserRequest $request
 @param UserRepository $userRepository
Creates a new user @param RegisterUserRequest $request @param UserRepository $userRepository