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