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