Trying to use ConnectionFactory class created by singleton in DatabaseServiceProvider

So Tapestry has its default DatabaseServiceProvider.php file containing the code below.

$this->app->singleton('db.factory', function ($app) {
    return new ConnectionFactory($app);
});

      

I want to use the facade created by this db.factory to create a new connection. But when I call

db.factory::make($config,$factory);

      

Of course it doesn't work, I get the error:

Using undefined constant db - 'db' assumed

How can i do this?

+3


source to share


1 answer


This singleton must be available directly through the service container. My favorite way to do this is with a helper function app()

:



app('db.factory')->make($config, $factory);

      

+2


source







All Articles