form = PaymentForm::setAttributes()->toArray(); $this->modules = $this->modules(config('realestate.payment.modules'), 'payment', guard_url('payment')); $this->repository = $payment; } /** * Display a list of payment. * * @return Response */ public function index(PaymentRequest $request) { $pageLimit = $request->input('pageLimit', config('database.pagination.limit')); $data = $this->repository ->pushFilter(RequestFilter::class) ->pushFilter(PaymentResourceFilter::class) ->setPresenter(PaymentListPresenter::class) ->simplePaginate($pageLimit) // ->withQueryString() ->toArray(); extract($data); $form = $this->form; $modules = $this->modules; return $this->response->setMetaTitle(trans('payment::payment.names')) ->view('payment::payment.index') ->data(compact('data', 'meta', 'links', 'modules', 'form')) ->output(); } /** * Display payment. * * @param Request $request * @param Model $payment * * @return Response */ public function show(PaymentRequest $request, PaymentRepositoryInterface $repository) { $form = $this->form; $modules = $this->modules; $data = $repository->toArray(); return $this->response ->setMetaTitle(trans('app.view') . ' ' . trans('payment::payment.name')) ->data(compact('data', 'form', 'modules', 'form')) ->view('payment::payment.show') ->output(); } /** * Show the form for creating a new payment. * * @param Request $request *x * @return Response */ public function create(PaymentRequest $request, PaymentRepositoryInterface $repository) { $form = $this->form; $modules = $this->modules; $data = $repository->toArray(); 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(PaymentRequest $request, PaymentRepositoryInterface $repository) { try { $attributes = $request->all(); $attributes['user_id'] = user_id(); $attributes['user_type'] = user_type(); $repository->create($attributes); $data = $repository->toArray(); 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/' . $data['id'])) ->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(PaymentRequest $request, PaymentRepositoryInterface $repository) { $form = $this->form; $modules = $this->modules; $data = $repository->toArray(); 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(PaymentRequest $request, PaymentRepositoryInterface $repository) { try { $attributes = $request->all(); $repository->update($attributes); $data = $repository->toArray(); 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/' . $data['id'])) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('payment/payment/' . $repository->getRouteKey())) ->redirect(); } } /** * Remove the payment. * * @param Model $payment * * @return Response */ public function destroy(PaymentRequest $request, PaymentRepositoryInterface $repository) { try { $repository->delete(); $data = $repository->toArray(); 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/' . $repository->getRouteKey())) ->redirect(); } } }