middleware(function ($request, $next) { $this->form = GatewayForm::grouped(false) ->setAttributes() ->toArray(); $this->modules = $this->modules(config('bixo.payment.modules'), 'payment', guard_url('payment')); return $next($request); }); } /** * Display a list of gateway. * * @return Response */ public function index(GatewayResourceRequest $request) { $request = $request->all(); $page = GatewayActions::run('paginate', $request); $data = new GatewaysCollection($page); $form = $this->form; $modules = $this->modules; return $this->response->setMetaTitle(trans('payment::gateway.names')) ->view('payment::gateway.index') ->data(compact('data', 'modules', 'form')) ->output(); } /** * Display gateway. * * @param Request $request * @param Model $gateway * * @return Response */ public function show(GatewayResourceRequest $request, Gateway $model) { $form = $this->form; $modules = $this->modules; $data = new GatewayResource($model); return $this->response ->setMetaTitle(trans('app.view') . ' ' . trans('payment::gateway.name')) ->data(compact('data', 'form', 'modules')) ->view('payment::gateway.show') ->output(); } /** * Show the form for creating a new gateway. * * @param Request $request * * @return Response */ public function create(GatewayResourceRequest $request, Gateway $model) { $form = $this->form; $modules = $this->modules; $data = new GatewayResource($model); return $this->response->setMetaTitle(trans('app.new') . ' ' . trans('payment::gateway.name')) ->view('payment::gateway.create') ->data(compact('data', 'form', 'modules')) ->output(); } /** * Create new gateway. * * @param Request $request * * @return Response */ public function store(GatewayResourceRequest $request, Gateway $model) { try { $request = $request->all(); $model = GatewayAction::run('store', $model, $request); $data = new GatewayResource($model); return $this->response->message(trans('messages.success.created', ['Module' => trans('payment::gateway.name')])) ->code(204) ->data(compact('data')) ->status('success') ->url(guard_url('payment/gateway/' . $model->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('/payment/gateway')) ->redirect(); } } /** * Show gateway for editing. * * @param Request $request * @param Model $gateway * * @return Response */ public function edit(GatewayResourceRequest $request, Gateway $model) { $form = $this->form; $modules = $this->modules; $data = new GatewayResource($model); // return view('payment::gateway.edit', compact('data', 'form', 'modules')); return $this->response->setMetaTitle(trans('app.edit') . ' ' . trans('payment::gateway.name')) ->view('payment::gateway.edit') ->data(compact('data', 'form', 'modules')) ->output(); } /** * Update the gateway. * * @param Request $request * @param Model $gateway * * @return Response */ public function update(GatewayResourceRequest $request, Gateway $model) { try { $request = $request->all(); $model = GatewayAction::run('update', $model, $request); $data = new GatewayResource($model); return $this->response->message(trans('messages.success.updated', ['Module' => trans('payment::gateway.name')])) ->code(204) ->status('success') ->data(compact('data')) ->url(guard_url('payment/gateway/' . $model->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('payment/gateway/' . $model->getRouteKey())) ->redirect(); } } /** * Remove the gateway. * * @param Model $gateway * * @return Response */ public function destroy(GatewayResourceRequest $request, Gateway $model) { try { $request = $request->all(); $model = GatewayAction::run('destroy', $model, $request); $data = new GatewayResource($model); return $this->response->message(trans('messages.success.deleted', ['Module' => trans('payment::gateway.name')])) ->code(202) ->status('success') ->data(compact('data')) ->url(guard_url('payment/gateway/0')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('payment/gateway/' . $model->getRouteKey())) ->redirect(); } } }