Answer the question
In order to leave comments, you need to log in
How can I get an instance of the repository?
Hello members!
Tell me, how can I get an instance of an arbitrary repository from an arbitrary class, as if we received it using injection from a service container?
Answer the question
In order to leave comments, you need to log in
As far as I understand, the author needs to get the dependency inside the object that was not created through the container (and the dependencies are not injected, respectively). If so then:
public function __construct()
{
$this->userRepository = resolve(UserRepository::class);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question