From b39e60cbd713fa2f8e7d7313a366a85c35b190d9 Mon Sep 17 00:00:00 2001 From: Lupu Gheorghe <46172059+gheorghelupu17@users.noreply.github.com> Date: Mon, 4 Sep 2023 10:56:04 +0300 Subject: [PATCH] fix update logic (#281) --- app/Services/OrganizationService.php | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/app/Services/OrganizationService.php b/app/Services/OrganizationService.php index 71d446a3..29246d40 100644 --- a/app/Services/OrganizationService.php +++ b/app/Services/OrganizationService.php @@ -16,12 +16,6 @@ public static function update(Organization $organization, array $attributes) $key = $attributes->keys()->first(); $value = $attributes->get($key); - if (! \in_array($key, $organization->requiresApproval)) { - $organization->update($attributes->all()); - - return; - } - return match ($key) { 'counties' => $organization->counties() ->sync(collect($value)->pluck('id')), @@ -34,7 +28,9 @@ public static function update(Organization $organization, array $attributes) 'statute' => static::saveStatue($organization, $value), - default => $organization->fill($attributes->all())->saveForApproval(), + default => \in_array($key, $organization->requiresApproval) + ? $organization->fill($attributes->all())->saveForApproval() + : $organization->update($attributes->all()), }; }