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