mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 14:14:03 +00:00
22 lines
500 B
PHP
22 lines
500 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Stancl\Tenancy\Database\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Relations\MorphPivot;
|
|
use Stancl\Tenancy\Contracts\Syncable;
|
|
|
|
class TenantPivot extends MorphPivot
|
|
{
|
|
public static function booted(): void
|
|
{
|
|
static::saved(function (self $pivot) {
|
|
$parent = $pivot->pivotParent;
|
|
|
|
if ($parent instanceof Syncable && $parent->shouldSync()) {
|
|
$parent->triggerSyncEvent();
|
|
}
|
|
});
|
|
}
|
|
}
|