1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 11:14:04 +00:00
tenancy/tests/Etc/ResourceSyncing/CentralUser.php
lukinovec ff95c92134 Add SyncedResourceDeleted event and DeleteResourceMapping listener
Also move pivot record deletion to that listener and improve tests
2025-11-14 11:21:28 +01:00

52 lines
1.2 KiB
PHP

<?php
declare(strict_types=1);
namespace Stancl\Tenancy\Tests\Etc\ResourceSyncing;
use Illuminate\Database\Eloquent\Model;
use Stancl\Tenancy\Database\Concerns\CentralConnection;
use Stancl\Tenancy\ResourceSyncing\ResourceSyncing;
use Stancl\Tenancy\ResourceSyncing\SyncMaster;
class CentralUser extends Model implements SyncMaster
{
use ResourceSyncing, CentralConnection;
protected $guarded = [];
public $timestamps = false;
public $table = 'users';
public static array $syncedAttributes = [];
public static array $creationAttributes = [];
public static bool $shouldSync = true;
public function getTenantModelName(): string
{
return TenantUser::class;
}
public function shouldSync(): bool
{
return static::$shouldSync;
}
public function getCentralModelName(): string
{
return static::class;
}
public function getSyncedAttributeNames(): array
{
return static::$syncedAttributes;
}
public function getCreationAttributes(): array
{
return count(static::$creationAttributes) ? static::$creationAttributes : $this->getSyncedAttributeNames();
}
}