Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| SetOrganizationOwnerAction | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
| execute | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace ImovelZapAi\Organizations\Application\Actions; |
| 6 | |
| 7 | use App\Models\User; |
| 8 | use ImovelZapAi\Tenancy\Infrastructure\Persistence\Eloquent\TenantModel; |
| 9 | |
| 10 | final class SetOrganizationOwnerAction |
| 11 | { |
| 12 | public function execute(string $tenantId, string $userId): TenantModel |
| 13 | { |
| 14 | $tenant = TenantModel::query()->findOrFail($tenantId); |
| 15 | |
| 16 | User::query() |
| 17 | ->where('tenant_id', $tenantId) |
| 18 | ->whereKey($userId) |
| 19 | ->firstOrFail(); |
| 20 | |
| 21 | $tenant->forceFill(['owner_user_id' => $userId])->save(); |
| 22 | |
| 23 | return $tenant->fresh() ?? $tenant; |
| 24 | } |
| 25 | } |