You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Serviceprovider register
$this->app->resolving(FooAwareInterface::class, function ($instance, $app) {
$instance->setFoo($app->make(FooInterface::class));
});
It was all working great until i started using them with a Job. This kind of dependency injection does not work with Jobs.
I would very much like to have Jobs behave more like other classes in Laravel. The documentation lacks also on this subject. its documented that you should use handle instead of the constructor for DI because the constructor is used for the data. But it is not mentioned that jobs are treated in a whole different way by the DI Container.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I use aware interfaces in my application which are very easy to setup in Laravel using https://laravel.com/docs/8.x/container#container-events
It was all working great until i started using them with a Job. This kind of dependency injection does not work with Jobs.
I would very much like to have Jobs behave more like other classes in Laravel. The documentation lacks also on this subject. its documented that you should use
handle
instead of the constructor for DI because the constructor is used for the data. But it is not mentioned that jobs are treated in a whole different way by the DI Container.EDIT: Just found out; the same goes for Models...
Beta Was this translation helpful? Give feedback.
All reactions