mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 16:14:03 +00:00
remove getResourceTenantModelName method and use config
This commit is contained in:
parent
b25071323f
commit
f99a8222c9
2 changed files with 4 additions and 20 deletions
|
|
@ -7,7 +7,6 @@ namespace Stancl\Tenancy\Database\Concerns;
|
|||
use Illuminate\Database\Eloquent\Relations\MorphToMany;
|
||||
use Stancl\Tenancy\Contracts\Syncable;
|
||||
use Stancl\Tenancy\Contracts\UniqueIdentifierGenerator;
|
||||
use Stancl\Tenancy\Database\Models\Tenant;
|
||||
use Stancl\Tenancy\Database\Models\TenantMorphPivot;
|
||||
use Stancl\Tenancy\Events\SyncedResourceSaved;
|
||||
|
||||
|
|
@ -49,12 +48,7 @@ trait ResourceSyncing
|
|||
|
||||
public function tenants(): MorphToMany
|
||||
{
|
||||
return $this->morphToMany($this->getResourceTenantModelName(), 'tenant_resources', 'tenant_resources', 'resource_global_id', 'tenant_id', 'global_id')
|
||||
return $this->morphToMany(config('tenancy.tenant_model'), 'tenant_resources', 'tenant_resources', 'resource_global_id', 'tenant_id', 'global_id')
|
||||
->using(TenantMorphPivot::class);
|
||||
}
|
||||
|
||||
public function getResourceTenantModelName(): string // todo better name
|
||||
{
|
||||
return config('tenancy.tenant_model', Tenant::class);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,9 @@ use Stancl\Tenancy\Tests\Etc\Tenant;
|
|||
beforeEach(function () {
|
||||
config(['tenancy.bootstrappers' => [
|
||||
DatabaseTenancyBootstrapper::class,
|
||||
]]);
|
||||
],
|
||||
'tenancy.tenant_model' => ResourceTenantUsingPolymorphic::class,
|
||||
]);
|
||||
|
||||
Event::listen(TenantCreated::class, JobPipeline::make([CreateDatabase::class])->send(function (TenantCreated $event) {
|
||||
return $event->tenant;
|
||||
|
|
@ -203,12 +205,6 @@ class CentralUserUsingPolymorphic extends Model implements SyncMaster
|
|||
|
||||
public $table = 'users';
|
||||
|
||||
// override method to provide different tenant
|
||||
public function getResourceTenantModelName(): string
|
||||
{
|
||||
return ResourceTenantUsingPolymorphic::class;
|
||||
}
|
||||
|
||||
public function getTenantModelName(): string
|
||||
{
|
||||
return TenantUserUsingPolymorphic::class;
|
||||
|
|
@ -286,12 +282,6 @@ class CentralCompanyUsingPolymorphic extends Model implements SyncMaster
|
|||
|
||||
public $table = 'companies';
|
||||
|
||||
// override method to provide different tenant
|
||||
public function getResourceTenantModelName(): string
|
||||
{
|
||||
return ResourceTenantUsingPolymorphic::class;
|
||||
}
|
||||
|
||||
public function getTenantModelName(): string
|
||||
{
|
||||
return TenantCompanyUsingPolymorphic::class;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue