ken4ward's avatar

Object of class App\\Repository\\UserRepository could not be converted to string

I am presently using the repository but kept getting the error

UserRepository class

    {
        $users = User::all();
        return $users;
    }```

Object of class App\Repository\UserRepository could not be converted to string.

THis is the controller class
```public function show()
    {
        $user = $this->$userRepository->getAll();
        $response = $this->response->item($user, new UserTransformer());
    }```

Kindly help.
0 likes
5 replies
Sergiu17's avatar

$this->$userRepository

Unnecessary dollar sign, this is first what I see

3 likes
ken4ward's avatar

I'm very grateful for this. Solved it brilliantly.

jlrdw's avatar

I'm very grateful for this. Solved it brilliantly.

Could you mark the answer that helped as answered to further assist others.

1 like
ken4ward's avatar

@JLRDW - Whenever I tried voting the right answer it returns a 404 error page.

Please or to participate in this conversation.