File tree 1 file changed +9
-5
lines changed
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
47
47
->where ('value ' , $ request ->get ('value ' ))
48
48
->first ();
49
49
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
+ }
54
58
} else {
55
- throw new Exception ( ' Selection value already exists. ' , 400 );
59
+ $ selectionValue = $ this -> selectionValue :: query ()-> create ( $ request -> validated () );
56
60
}
57
61
} else {
58
62
$ selectionValue = $ this ->selectionValue ::query ()->create ($ request ->validated ());
You can’t perform that action at this time.
0 commit comments