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