class MyServiceProvider extends ServiceProvider
{
public $foo;
public function __construct($app)
{
parent::__construct($app);
if ($someCondition) {
$this->foo = $app->make(OneServiceProvider::class);
} else {
$this->foo = $app->make(AnotherServiceProvider::class);
}
}
public function register()
{
$this->app->singleton(self::class, function ($app) {
return new static($app);
});
}
}
I'm getting an error:
Unresolvable dependency resolving [Parameter #0 [ <required> $app ]] in class App\xxx\AnotherServiceProvider