ORT-Interactive-GmbH / laravel-couchbase

A Couchbase based Eloquent model and Query builder for Laravel
40 stars 26 forks source link

Bugfix to current DB connection #4

Closed spresnac closed 6 years ago

spresnac commented 7 years ago

Please fix your `CouchbaseServiceProvider::register()' to this:

    /**
     * Register the service provider.
     */
    public function register()
    {
        // Add database driver.
        $this->app->singleton('couchbase.connection', function($app){
            $connectionName = config('database.connections.'.config('database.default'));
            return new Connection($connectionName);
        });
        $this->app->resolving('db', function ($db) {
            $db->extend('couchbase', function ($config) {
                return app('couchbase.connection');
            });
        });
    }

This will enable the usage of the current used connection. Yet, this function only uses the 'couchbase'-named configuration.