1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-06 01:14:03 +00:00

separate pivot model for each approach

This commit is contained in:
Abrar Ahmad 2022-11-10 14:36:58 +05:00
parent dfe1fcecb5
commit b08961150c
4 changed files with 31 additions and 10 deletions

View file

@ -8,6 +8,7 @@ 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\Database\Models\TenantPivot;
use Stancl\Tenancy\Events\SyncedResourceSaved;
@ -50,7 +51,7 @@ trait ResourceSyncing
public function tenants(): MorphToMany
{
return $this->morphToMany($this->getResourceTenantModelName(), 'tenant_resources', 'tenant_resources', 'resource_global_id', 'tenant_id', 'global_id')
->using(TenantPivot::class);
->using(TenantMorphPivot::class);
}
public function getResourceTenantModelName(): string // todo better name