File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed
Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -47,12 +47,16 @@ public function store(SelectionValueRequest $request): JsonResponse
4747 ->where ('value ' , $ request ->get ('value ' ))
4848 ->first ();
4949
50- if ($ selectionValue ->trashed ()) {
51- // restore
52- $ selectionValue ->restoreQuietly ();
53- $ selectionValue ->update ($ request ->validated ());
50+ if ($ selectionValue ) {
51+ if ($ selectionValue ->trashed ()) {
52+ // restore
53+ $ selectionValue ->restoreQuietly ();
54+ $ selectionValue ->update ($ request ->validated ());
55+ } else {
56+ throw new Exception ('Selection value already exists. ' , 400 );
57+ }
5458 } else {
55- throw new Exception ( ' Selection value already exists. ' , 400 );
59+ $ selectionValue = $ this -> selectionValue :: query ()-> create ( $ request -> validated () );
5660 }
5761 } else {
5862 $ selectionValue = $ this ->selectionValue ::query ()->create ($ request ->validated ());
You can’t perform that action at this time.
0 commit comments