1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 17:24:03 +00:00

Get rid of tenant DB manager connection config

This commit is contained in:
Samuel Štancl 2020-05-21 14:47:29 +02:00
parent 2fedd5ce88
commit 15a7e52208
11 changed files with 58 additions and 41 deletions

View file

@ -4,24 +4,23 @@ declare(strict_types=1);
namespace Stancl\Tenancy\TenantDatabaseManagers;
use Illuminate\Contracts\Config\Repository;
use Illuminate\Database\Connection;
use Illuminate\Support\Facades\DB;
use Stancl\Tenancy\Contracts\TenantDatabaseManager;
use Stancl\Tenancy\Contracts\TenantWithDatabase;
use Stancl\Tenancy\Exceptions\NoConnectionSetException;
class PostgreSQLDatabaseManager implements TenantDatabaseManager
{
/** @var string */
protected $connection;
public function __construct(Repository $config)
{
$this->connection = $config->get('tenancy.database_manager_connections.pgsql');
}
protected function database(): Connection
{
if ($this->connection === null) {
throw new NoConnectionSetException(static::class);
}
return DB::connection($this->connection);
}