andersao / l5-repository

Laravel 5 - Repositories to abstract the database layer
http://andersao.github.io/l5-repository
MIT License
4.19k stars 876 forks source link

Interface not instantiable while building class (Model observer) #724

Open yoerriwalstra opened 4 years ago

yoerriwalstra commented 4 years ago

Hi,

I'm using a Model observer to create related entries on the Model's created event. I'm using this repository package to communicate with my database. I bind the RepositoryInterfaces to their concrete classes in my RepositoryServiceProvider, which I added to the 'providers' array in my config/app.php. When my Observer runs, however, I get the following error:

Target [App\Repositories\Interfaces\ExamAttemptQuestionRepositoryInterface] is not instantiable while building [App\Observers\ExamAttemptObserver].

I've created a little test interface MyInterface, implemented it in MyClass and bound the interface to the implementation in my RepositoryServiceProvider, just like I did with all my other repositories. The observer doesn't throw an exception when I resolve MyInterface in the constructor.

interface MyInterface
{
    public function test(): string;
}

I've raised an issue on Laracasts, but was hoping to also get help from here, since I'm unsure if where the issue originates.

Kinds regards,

kalibano commented 4 years ago

facing the same issue after updating laravel 6.2 to 6.9.