I would like to find a good way to pass a pre-configured object to a controller. I know that I can use IoC as shown below:
Mycontroller extends extends \Illuminate\Routing\Controllers\Controller { //i can only use one config uless i pass Request data $this->config = App::make('MyconfigObject'); }
but this seems to limit the ability to use only one configuration. I would rather do something like the following:
Route::get('some-route', function() { $config = Config::get('some.config'); $object = new MyConfigObject($config); Route::dispatch(MyController($object)); });
The reason I would like to do this is because I would like to send the same controller, but with a different configuration for multiple routes.
source share