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