mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 20:34:03 +00:00
Revert "Get rid of TenantDatabaseDoesNotExist exception"
This reverts commit fe52a3c4ea.
This commit is contained in:
parent
9ed46bbc35
commit
41aead5da2
6 changed files with 27 additions and 3 deletions
|
|
@ -7,6 +7,7 @@ namespace Stancl\Tenancy\Bootstrappers;
|
|||
use Stancl\Tenancy\Contracts\TenancyBootstrapper;
|
||||
use Stancl\Tenancy\Contracts\Tenant;
|
||||
use Stancl\Tenancy\Database\DatabaseManager;
|
||||
use Stancl\Tenancy\Exceptions\TenantDatabaseDoesNotExistException;
|
||||
|
||||
class DatabaseTenancyBootstrapper implements TenancyBootstrapper
|
||||
{
|
||||
|
|
@ -20,6 +21,12 @@ class DatabaseTenancyBootstrapper implements TenancyBootstrapper
|
|||
|
||||
public function bootstrap(Tenant $tenant)
|
||||
{
|
||||
/** @var TenantWithDatabase $tenant */
|
||||
$database = $tenant->database()->getName();
|
||||
if (! $tenant->database()->manager()->databaseExists($database)) {
|
||||
throw new TenantDatabaseDoesNotExistException($database);
|
||||
}
|
||||
|
||||
$this->database->connectToTenant($tenant);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ class TenantCouldNotBeIdentifiedByPathException extends TenantCouldNotBeIdentifi
|
|||
return BaseSolution::create('Tenant could not be identified on this path')
|
||||
->setSolutionDescription('Did you forget to create a tenant for this path?')
|
||||
->setDocumentationLinks([
|
||||
'Creating Tenants' => 'https://tenancyforlaravel.com/docs/v3/tenants/',
|
||||
'Creating Tenants' => 'https://tenancyforlaravel.com/docs/v2/creating-tenants/', // todo update link for v3
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ class TenantCouldNotBeIdentifiedByRequestDataException extends TenantCouldNotBeI
|
|||
return BaseSolution::create('Tenant could not be identified with this request data')
|
||||
->setSolutionDescription('Did you forget to create a tenant with this id?')
|
||||
->setDocumentationLinks([
|
||||
'Creating Tenants' => 'https://tenancyforlaravel.com/docs/v3/tenants/',
|
||||
'Creating Tenants' => 'https://tenancyforlaravel.com/docs/v2/creating-tenants/', // todo update link for v3
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ class TenantCouldNotBeIdentifiedOnDomainException extends TenantCouldNotBeIdenti
|
|||
return BaseSolution::create('Tenant could not be identified on this domain')
|
||||
->setSolutionDescription('Did you forget to create a tenant for this domain?')
|
||||
->setDocumentationLinks([
|
||||
'Creating Tenants' => 'https://tenancyforlaravel.com/docs/v3/tenants/',
|
||||
'Creating Tenants' => 'https://tenancyforlaravel.com/docs/v2/creating-tenants/', // todo update link for v3
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
15
src/Exceptions/TenantDatabaseDoesNotExistException.php
Normal file
15
src/Exceptions/TenantDatabaseDoesNotExistException.php
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stancl\Tenancy\Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
class TenantDatabaseDoesNotExistException extends Exception
|
||||
{
|
||||
public function __construct($database)
|
||||
{
|
||||
parent::__construct("Database $database does not exist.");
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue