laravel 5 - How to pass arguments from resolve() to callback specified in give()? -


constructor of class requires instance of class b, constructor in turn takes optional string argument.

i want able specify value of string argument class b constructor when resolving class a. want something in service provider:

$this->app     ->when(a::class)     ->needs(b::class)     ->give(function($argument_for_b /* <-- here */){          return new b($argument_for_b);      }) 

and obtain instance of (assuming has been bound ainterface in container):

$ainstance = resolve(ainterface::class /* how pass argument b? */); 


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -