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