mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 18:04:03 +00:00
Get rid of tenant DB manager connection config
This commit is contained in:
parent
2fedd5ce88
commit
15a7e52208
11 changed files with 58 additions and 41 deletions
|
|
@ -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 MySQLDatabaseManager implements TenantDatabaseManager
|
||||
{
|
||||
/** @var string */
|
||||
protected $connection;
|
||||
|
||||
public function __construct(Repository $config)
|
||||
{
|
||||
$this->connection = $config->get('tenancy.database_manager_connections.mysql');
|
||||
}
|
||||
|
||||
protected function database(): Connection
|
||||
{
|
||||
if ($this->connection === null) {
|
||||
throw new NoConnectionSetException(static::class);
|
||||
}
|
||||
|
||||
return DB::connection($this->connection);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,19 +9,19 @@ 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 PostgreSQLSchemaManager 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);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue