all(); $acknowledgement_detail = AcknowledgementDetailWorkflow::run($trasition, $acknowledgement_detail, $request); $data = new AcknowledgementDetailResource($acknowledgement_detail); return $this->response->message(trans('messages.success.updated', ['Module' => trans('account::acknowledgement_detail.name')])) ->code(204) ->data(compact('data')) ->status('success') ->url(guard_url('account/acknowledgement_detail/' . $acknowledgement_detail->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('account/acknowledgement_detail/' . $acknowledgement_detail->getRouteKey())) ->redirect(); } } /** * Get the acknowledgement_detail and user for the workflow. * * @param PublicRequest $request * @param string $acknowledgement_detail * @param string $user * * @return Response */ public function get(PublicRequest $request, $acknowledgement_detail, $user) { if (!$request->hasValidSignature()) { abort(403, 'This url is expired!'); } $auth = Auth::guard()->getProvider()->getModel(); $user = $auth::findBySignedId($user); Auth::guard()->login($user); $acknowledgement_detail = AcknowledgementDetail::findBySignedId($acknowledgement_detail); $transitions = $this->transitions($acknowledgement_detail, $user); $user = user(); Auth::logout(); return $this->response->setMetaTitle(trans('account::acknowledgement_detail.name') . ' ' . trans('Approvals')) ->view('account::public.acknowledgement_detail.workflow') ->layout('mobile') ->data(compact('acknowledgement_detail', 'user', 'transitions')) ->output(); } /** * Display the workflow form for the acknowledgement_detail. * * @param PublicRequest $request * @param string $acknowledgement_detail * @param string $user * * @return Response */ public function post(PublicRequest $request, $acknowledgement_detail, $user) { if (!$request->hasValidSignature()) { abort(403, 'This url is expired!'); } $transition = $request->transition; $auth = Auth::guard()->getProvider()->getModel(); $user = $auth::findBySignedId($user); Auth::guard()->login($user); $acknowledgement_detail = AcknowledgementDetail::findBySignedId($acknowledgement_detail); $user = user(); $acknowledgement_detail = AcknowledgementDetailWorkflow::run($transition, $acknowledgement_detail, $request->all()); Auth::logout(); return response()->json( [ 'status' => 'success', 'url' => $request->url(), ] ); } private function transitions($acknowledgement_detail, $user) { $transitions = []; foreach ($acknowledgement_detail->workflow()->transitions($acknowledgement_detail) as $key => $value) { $name = $value->getName(); $array['url'] = URL::temporarySignedRoute('litecms.acknowledgement_detail.workflow', now()->addMinutes(3), [ 'guard' => 'admin', 'transition' => $name, 'acknowledgement_detail' => $acknowledgement_detail->getSignedId(now()->addMinutes(3)), 'user' => $user->getSignedId(now()->addMinutes(3)), 'trans' => 'en', ] ); $array['name'] = $name; $array['key'] = $name; $array['form'] = $acknowledgement_detail->workflow()->form($value); $array['label'] = trans('account::acknowledgement_detail.workflow.' . $name); $transitions[] = $array; } return $transitions; } }