1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-06 02:54:06 +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

@ -0,0 +1,22 @@
<?php
declare(strict_types=1);
namespace Stancl\Tenancy\Database\Models;
use Illuminate\Database\Eloquent\Relations\MorphPivot;
use Stancl\Tenancy\Contracts\Syncable;
class TenantMorphPivot extends MorphPivot
{
public static function booted(): void
{
static::saved(function (self $pivot) {
$parent = $pivot->pivotParent;
if ($parent instanceof Syncable && $parent->shouldSync()) {
$parent->triggerSyncEvent();
}
});
}
}