Make a tenantor instance.

@param  string  $name
@param  mixed  $key
@param  string|null  $connection
@param  \Illuminate\Database\Eloquent\Model|null  $model

@return static
960232
public static function make(string $name, $key, ?string $connection = null, ?Model $model = null)
    {
        return new static(\compact('name', 'key', 'connection', 'model'));
    }
170600
public function create($name)
    {
        $config = $this->getConfiguration($name);

        if(null === $config) {
            throw new \RuntimeException(
                "Connection with name: $name not found."
            );
        }

        return new Client($config);
    }
12704
public function connection($name = null)
    {
        if ( ! isset($this->connections[$name]))
        {
            $this->connections[$name] = $this->createConnection($name);
        }

        return $this->connections[$name];
    }
1253104
public function getEntityManager(string $connection = 'default'): EntityManager
    {
        if (!isset($this->entityManager[$connection])) {
            $this->entityManager[$connection] = new EntityManager($this->getConnection($connection));
        }

        return $this->entityManager[$connection];
    }
556769
public function addConnection(string $name = null, Connection $connection = null): self
    {
        if (is_null($name)) {
            $this->defaultConnection = $connection;
        } else {
            $this->registry[$name] = $connection;
        }

        return $this;
    }
859211
public static function connection($name)
    {
        $schema = static::$app['db']->connection($name)->getSchemaBuilder();
        $schema->blueprintResolver(function ($table, $callback) {
            return new Blueprint($table, $callback);
        });

        return $schema;
    }
1039428
public static function createNormalizer($key = 'default')
    {
        return isset(self::$instancePool[$key]) ?
            self::$instancePool[$key] :
            self::$instancePool[$key] = new static(
            PropertyAccess::createPropertyAccessor()
        );
    }
409580
public function getAdminConnection($name = null)
    {
        if (null === $name) {
            $name = $this->getDefaultConnectionName();
        }

        $serviceName = sprintf('doctrine_phpcr.admin.%s_session', $name);

        $connections = $this->getConnectionNames();
        if (!isset($connections[$name])) {
            throw new \InvalidArgumentException(sprintf('Doctrine %s Connection named "%s" does not exist.', $this->getName(), $name));
        }

        return $this->getService($serviceName);
    }
937621
public function getConnection($name = null)
    {
        if (null === $name) {
            $name = $this->defaultConnection;
        }

        if (!isset($this->connections[$name])) {
            throw new \InvalidArgumentException(sprintf('AMQP Connection named "%s" does not exist.', $name));
        }

        return $this->connections[$name];
    }
119603
public function connection($name = null)
    {
        if (is_null($name)) {
            $name = $this->getDefaultConnection();
        }

        return $this->connections[$name];
    }
293972
public function connection($name = null)
    {
        if (is_null($name)) {
            $name = $this->getDefaultConnection();
        }

        if (! isset($this->connections[$name])) {
            throw new InvalidArgumentException("Connection [{$name}] is not registered.");
        }

        return $this->connections[$name];
    }
553276
public function newFromBuilder($attributes = array(), $connection = null) {
    $typeField = static::$singleTableTypeField;
    $attributes = (array) $attributes;

    $classType = array_key_exists($typeField, $attributes) ? $attributes[$typeField] : null;

    if ($classType !== null) {
      $childTypes = static::getSingleTableTypeMap();
      if (array_key_exists($classType, $childTypes)) {
        $class = $childTypes[$classType];
        $instance = (new $class)->newInstance([], true);
        $instance->setFilteredAttributes($attributes);
        $instance->setConnection($connection ?: $this->getConnectionName());
        $instance->fireModelEvent('retrieved', false);
        return $instance;
      } else {
        // Something has gone very wrong with the Global Scope
        // There is not graceful recovery so complain loudly.
        throw new SingleTableInheritanceException("Cannot construct newFromBuilder for unrecognized $typeField=$classType");
      }
    } else {
      // There are some cases, like Model::pluck('id'), where $attributes does not contain classType
      // In those situations defer to the original implementation.
      return parent::newFromBuilder($attributes, $connection);
    }
  }
800332
public function alterField($name, Field $field, Key $key = null)
    {
        if (null !== $key) {
            $field->setKey($key);
        }

        $this->fields[$name] = $field;

        $this->alters[$name] = $field;

        return $this;
    }
551710
public static function get_conn($name = 'default')
    {
        if (isset(self::$connections[$name])) {
            return self::$connections[$name];
        }

        // lazy connect
        $config = static::getConfig($name);
        if ($config) {
            return static::connect($config, $name);
        }

        return null;
    }
592318
public function connection($name = null)
    {
        $name = $name ?: $this->getDefaultDriver();

        // If the connection has not been resolved yet we will resolve it now as all
        // of the connections are resolved when they are actually needed so we do
        // not make any unnecessary connection to the various queue end-points.
        if ( ! isset($this->connections[$name])) {
            $this->connections[$name] = $this->resolve($name);

            $this->connections[$name]->setContainer($this->app);

            $this->connections[$name]->setEncrypter($this->app['encrypter']);
        }

        return $this->connections[$name];
    }
230182
public function service($name, $key = 'main')
    {
        $service = Service::get($name, $key);

        if ($service instanceof NoopService) {
            return $service;
        }

        return $service->setSchema($this);
    }
1325231
public function create(Name $name)
    {
        $factory = $this->factoryMap->hasFactory($name)
            ? $this->factoryMap->getFactory($name)
            : $this->defaultTransactionFactory;

        return new IsolateContext($name, $factory);
    }