@@ -499,6 +499,7 @@ public function update(Request $request, Process $process)
499499 $ lastVersion = $ process ->getDraftOrPublishedLatestVersion ();
500500 $ process ->bpmn = $ lastVersion ->bpmn ;
501501 $ process ->alternative = $ lastVersion ->alternative ;
502+ $ process ->stages = $ lastVersion ->stages ;
502503
503504 $ rules = Process::rules ($ process );
504505 if (!$ request ->has ('name ' )) {
@@ -2089,24 +2090,22 @@ public function saveStages(Request $request, Process $process)
20892090 $ stages = $ request ->input ('stages ' );
20902091
20912092 if ($ alternative === 'B ' ) {
2092-
2093- // Get or create alternative B version
2094- $ alternativeVersion = ProcessVersion::where ('process_id ' , $ process ->id )
2093+ ProcessVersion::where ('process_id ' , $ process ->id )
20952094 ->where ('alternative ' , 'B ' )
2096- ->first ();
2097-
2098- // Save stages to alternative B version
2099- $ alternativeVersion ->stages = $ stages ;
2100- $ alternativeVersion ->save ();
2101-
2102- return new ApiCollection ($ alternativeVersion ->stages );
2095+ ->update ([
2096+ 'stages ' => $ stages ,
2097+ ]);
21032098 } else {
2104- // Save stages to main process (alternative A)
2099+ ProcessVersion::where ('process_id ' , $ process ->id )
2100+ ->where ('alternative ' , 'A ' )
2101+ ->update ([
2102+ 'stages ' => $ stages ,
2103+ ]);
21052104 $ process ->stages = $ stages ;
21062105 $ process ->save ();
2107-
2108- return new ApiCollection ($ process ->stages );
21092106 }
2107+
2108+ return new ApiCollection ($ stages );
21102109 }
21112110
21122111 /**
0 commit comments