public function asDefaultConnection(Model $entity, ?string $database): ?string
    {
        $connection = $this->asConnection($entity, $database);

        $this->app->make('config')->set('database.default', $connection);

        return $connection;
    }
public function asDefaultConnection(Model $entity, ?string $database): ?string
    {
        $connection = $this->asConnection($entity, $database);

        $this->app->make('config')->set('database.default', $connection);

        return $connection;
    }
public function asDefaultConnection ( Model $ entity , ? string $ database ) : ? string { $ connection = $ this -> asConnection ( $ entity , $ database ) ; $ this -> app -> make ( 'config' ) -> set ( 'database.default' , $ connection ) ; return $ connection ; }
Set tenant as default database connection and get the connection name.

@param  \Illuminate\Database\Eloquent\Model  $entity
@param  string|null  $database

@return string|null
Set tenant as default database connection and get the connection name .