Skip to content

Commit

Permalink
fix update logic (#281)
Browse files Browse the repository at this point in the history
  • Loading branch information
gheorghelupu17 authored Sep 4, 2023
1 parent 8691827 commit b39e60c
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions app/Services/OrganizationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')),
Expand All @@ -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()),
};
}

Expand Down

0 comments on commit b39e60c

Please sign in to comment.