28 lines
657 B
PHP
28 lines
657 B
PHP
<?php
|
|
|
|
namespace App\Services\Tenant;
|
|
|
|
use App\Models\Tenant;
|
|
use App\Models\TenantLifecycleEvent;
|
|
use App\Models\User;
|
|
use Carbon\CarbonInterface;
|
|
|
|
class TenantLifecycleLogger
|
|
{
|
|
public function record(
|
|
Tenant $tenant,
|
|
string $type,
|
|
array $payload = [],
|
|
?User $actor = null,
|
|
?CarbonInterface $occurredAt = null
|
|
): TenantLifecycleEvent {
|
|
return TenantLifecycleEvent::create([
|
|
'tenant_id' => $tenant->getKey(),
|
|
'actor_id' => $actor?->getKey(),
|
|
'type' => $type,
|
|
'payload' => $payload,
|
|
'occurred_at' => $occurredAt ?? now(),
|
|
]);
|
|
}
|
|
}
|