Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
RevokeInvitationAction
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 1
 execute
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 1
6
1<?php
2
3declare(strict_types=1);
4
5namespace ImovelZapAi\Organizations\Application\Actions;
6
7use ImovelZapAi\Organizations\Domain\Enums\InvitationStatus;
8use ImovelZapAi\Organizations\Infrastructure\Persistence\Eloquent\OrganizationInvitationModel;
9use RuntimeException;
10
11final class RevokeInvitationAction
12{
13    public function execute(string $tenantId, string $invitationId): void
14    {
15        $invitation = OrganizationInvitationModel::query()
16            ->where('tenant_id', $tenantId)
17            ->whereKey($invitationId)
18            ->first();
19
20        if ($invitation === null) {
21            throw new RuntimeException('Convite não encontrado.');
22        }
23
24        $invitation->forceFill(['status' => InvitationStatus::Revoked])->save();
25    }
26}