Skip to content

Commit

Permalink
fix custom field selection values add new (#95)
Browse files Browse the repository at this point in the history
* hf

fix new

* Apply fixes from StyleCI

---------

Co-authored-by: StyleCI Bot <[email protected]>
  • Loading branch information
ngaspari and StyleCIBot authored Oct 21, 2024
1 parent 00c6451 commit fc21dba
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/App/Http/Controllers/SelectionValueController.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,16 @@ public function store(SelectionValueRequest $request): JsonResponse
->where('value', $request->get('value'))
->first();

if ($selectionValue->trashed()) {
// restore
$selectionValue->restoreQuietly();
$selectionValue->update($request->validated());
if ($selectionValue) {
if ($selectionValue->trashed()) {
// restore
$selectionValue->restoreQuietly();
$selectionValue->update($request->validated());
} else {
throw new Exception('Selection value already exists.', 400);
}
} else {
throw new Exception('Selection value already exists.', 400);
$selectionValue = $this->selectionValue::query()->create($request->validated());
}
} else {
$selectionValue = $this->selectionValue::query()->create($request->validated());
Expand Down

0 comments on commit fc21dba

Please sign in to comment.