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