Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
10 / 10 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| PortalActivityWriter | |
100.00% |
10 / 10 |
|
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
| write | |
100.00% |
10 / 10 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace ImovelZapAi\ClientPortal\Application\Services; |
| 6 | |
| 7 | use ImovelZapAi\ClientPortal\Domain\Enums\PortalActivityEvent; |
| 8 | use ImovelZapAi\ClientPortal\Infrastructure\Persistence\Eloquent\PortalActivityModel; |
| 9 | |
| 10 | final class PortalActivityWriter |
| 11 | { |
| 12 | /** |
| 13 | * @param array<string, mixed>|null $payload |
| 14 | */ |
| 15 | public function write( |
| 16 | string $tenantId, |
| 17 | string $portalId, |
| 18 | PortalActivityEvent $event, |
| 19 | string $actorType = 'system', |
| 20 | ?int $actorUserId = null, |
| 21 | ?array $payload = null, |
| 22 | ?string $message = null, |
| 23 | ): void { |
| 24 | PortalActivityModel::query()->create([ |
| 25 | 'tenant_id' => $tenantId, |
| 26 | 'client_portal_id' => $portalId, |
| 27 | 'event' => $event, |
| 28 | 'actor_type' => $actorType, |
| 29 | 'actor_user_id' => $actorUserId, |
| 30 | 'payload' => $payload, |
| 31 | 'message' => $message, |
| 32 | 'created_at' => now(), |
| 33 | ]); |
| 34 | } |
| 35 | } |