mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 12:54:05 +00:00
Resolve test to-dos (#45)
* Only retrieve domains if the relationship and the domains table exist (DomianTenantResolver) * Resolve todo, add other todos * Use constructor promotion in DeleteDomains * Fix imports + domain deletion test * Confirm that turning on resolver caching doesn't break the tests * Fix Tenant model imports * Fix code style (php-cs-fixer) * remove runtime schema check * temp: enable resolver cache * make 'autoincrement ids are supported' pass * disable resolver cache --------- Co-authored-by: PHP CS Fixer <phpcsfixer@example.com> Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com> Co-authored-by: Samuel Štancl <samuel@archte.ch>
This commit is contained in:
parent
3e441e075f
commit
6e67ddf7a5
18 changed files with 85 additions and 80 deletions
|
|
@ -15,12 +15,9 @@ class DeleteDomains
|
|||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
protected TenantWithDatabase&Model $tenant;
|
||||
|
||||
public function __construct(TenantWithDatabase&Model $tenant)
|
||||
{
|
||||
$this->tenant = $tenant;
|
||||
}
|
||||
public function __construct(
|
||||
protected TenantWithDatabase&Model $tenant,
|
||||
) {}
|
||||
|
||||
public function handle(): void
|
||||
{
|
||||
|
|
|
|||
|
|
@ -4,13 +4,15 @@ declare(strict_types=1);
|
|||
|
||||
namespace Stancl\Tenancy\Resolvers;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Stancl\Tenancy\Contracts\Domain;
|
||||
use Stancl\Tenancy\Contracts\SingleDomainTenant;
|
||||
use Stancl\Tenancy\Contracts\Tenant;
|
||||
use Stancl\Tenancy\Exceptions\TenantCouldNotBeIdentifiedOnDomainException;
|
||||
use Stancl\Tenancy\Tenancy;
|
||||
use Stancl\Tenancy\Contracts\Domain;
|
||||
use Stancl\Tenancy\Contracts\Tenant;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Stancl\Tenancy\Contracts\SingleDomainTenant;
|
||||
use Illuminate\Database\Eloquent\Relations\Relation;
|
||||
use Stancl\Tenancy\Exceptions\TenantCouldNotBeIdentifiedOnDomainException;
|
||||
|
||||
class DomainTenantResolver extends Contracts\CachedTenantResolver
|
||||
{
|
||||
|
|
@ -69,12 +71,14 @@ class DomainTenantResolver extends Contracts\CachedTenantResolver
|
|||
|
||||
public function getPossibleCacheKeys(Tenant&Model $tenant): array
|
||||
{
|
||||
$domains = [];
|
||||
|
||||
if ($tenant instanceof SingleDomainTenant) {
|
||||
$domains = array_filter([
|
||||
$tenant->getOriginal('domain'), // Previous domain
|
||||
$tenant->domain, // Current domain
|
||||
]);
|
||||
} else {
|
||||
} elseif (method_exists($tenant, 'domains') && $tenant->domains() instanceof Relation) {
|
||||
/** @var Tenant&Model $tenant */
|
||||
$tenant->unsetRelation('domains');
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue