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