mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-16 01:24:04 +00:00
canCreate database
This commit is contained in:
parent
08319695b9
commit
de54b5708c
7 changed files with 60 additions and 7 deletions
|
|
@ -8,6 +8,7 @@ use Illuminate\Foundation\Application;
|
|||
use Stancl\Tenancy\Jobs\QueuedTenantDatabaseCreator;
|
||||
use Illuminate\Database\DatabaseManager as BaseDatabaseManager;
|
||||
use Stancl\Tenancy\Exceptions\DatabaseManagerNotRegisteredException;
|
||||
use Stancl\Tenancy\Exceptions\TenantDatabaseAlreadyExistsException;
|
||||
|
||||
class DatabaseManagerv2
|
||||
{
|
||||
|
|
@ -95,7 +96,11 @@ class DatabaseManagerv2
|
|||
*/
|
||||
public function canCreate(Tenant $tenant)
|
||||
{
|
||||
// todo
|
||||
if ($this->getTenantDatabaseManager($tenant)->databaseExists($database = $tenant->getDatabaseName())) {
|
||||
return new TenantDatabaseAlreadyExistsException($database);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function createDatabase(Tenant $tenant)
|
||||
|
|
@ -129,7 +134,7 @@ class DatabaseManagerv2
|
|||
|
||||
$databaseManagers = $this->app['config']['tenancy.database_managers'];
|
||||
|
||||
if (! \array_key_exists($driver, $databaseManagers)) {
|
||||
if (! array_key_exists($driver, $databaseManagers)) {
|
||||
throw new DatabaseManagerNotRegisteredException($driver);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue