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