form = GreenTagHealthBenefitsForm::setAttributes()->toArray(); $this->modules = $this->modules(config('litecms.green_tag.modules'), 'green_tag', guard_url('green_tag')); $this->repository = $green_tag_health_benefits; } /** * Display a list of green_tag_health_benefits. * * @return Response */ public function index(GreenTagHealthBenefitsRequest $request) { $pageLimit = $request->input('pageLimit', config('database.pagination.limit')); $data = $this->repository ->pushFilter(RequestFilter::class) ->pushFilter(GreenTagHealthBenefitsResourceFilter::class) ->setPresenter(GreenTagHealthBenefitsListPresenter::class) ->simplePaginate($pageLimit) // ->withQueryString() ->toArray(); extract($data); $form = $this->form; $modules = $this->modules; return $this->response->setMetaTitle(trans('green_tag::green_tag_health_benefits.names')) ->view('green_tag::green_tag_health_benefits.index') ->data(compact('data', 'meta', 'links', 'modules', 'form')) ->output(); } /** * Display green_tag_health_benefits. * * @param Request $request * @param Model $green_tag_health_benefits * * @return Response */ public function show(GreenTagHealthBenefitsRequest $request, GreenTagHealthBenefitsRepositoryInterface $repository) { $form = $this->form; $modules = $this->modules; $data = $repository->toArray(); return $this->response ->setMetaTitle(trans('app.view') . ' ' . trans('green_tag::green_tag_health_benefits.name')) ->data(compact('data', 'form', 'modules', 'form')) ->view('green_tag::green_tag_health_benefits.show') ->output(); } /** * Show the form for creating a new green_tag_health_benefits. * * @param Request $request *x * @return Response */ public function create(GreenTagHealthBenefitsRequest $request, GreenTagHealthBenefitsRepositoryInterface $repository) { $form = $this->form; $modules = $this->modules; $data = $repository->toArray(); return $this->response->setMetaTitle(trans('app.new') . ' ' . trans('green_tag::green_tag_health_benefits.name')) ->view('green_tag::green_tag_health_benefits.create') ->data(compact('data', 'form', 'modules')) ->output(); } /** * Create new green_tag_health_benefits. * * @param Request $request * * @return Response */ public function store(GreenTagHealthBenefitsRequest $request, GreenTagHealthBenefitsRepositoryInterface $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('green_tag::green_tag_health_benefits.name')])) ->code(204) ->data(compact('data')) ->status('success') ->url(guard_url('green_tag/green_tag_health_benefits/' . $data['id'])) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('/green_tag/green_tag_health_benefits')) ->redirect(); } } /** * Show green_tag_health_benefits for editing. * * @param Request $request * @param Model $green_tag_health_benefits * * @return Response */ public function edit(GreenTagHealthBenefitsRequest $request, GreenTagHealthBenefitsRepositoryInterface $repository) { $form = $this->form; $modules = $this->modules; $data = $repository->toArray(); return $this->response->setMetaTitle(trans('app.edit') . ' ' . trans('green_tag::green_tag_health_benefits.name')) ->view('green_tag::green_tag_health_benefits.edit') ->data(compact('data', 'form', 'modules')) ->output(); } /** * Update the green_tag_health_benefits. * * @param Request $request * @param Model $green_tag_health_benefits * * @return Response */ public function update(GreenTagHealthBenefitsRequest $request, GreenTagHealthBenefitsRepositoryInterface $repository) { try { $attributes = $request->all(); $repository->update($attributes); $data = $repository->toArray(); return $this->response->message(trans('messages.success.updated', ['Module' => trans('green_tag::green_tag_health_benefits.name')])) ->code(204) ->status('success') ->data(compact('data')) ->url(guard_url('green_tag/green_tag_health_benefits/' . $data['id'])) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('green_tag/green_tag_health_benefits/' . $repository->getRouteKey())) ->redirect(); } } /** * Remove the green_tag_health_benefits. * * @param Model $green_tag_health_benefits * * @return Response */ public function destroy(GreenTagHealthBenefitsRequest $request, GreenTagHealthBenefitsRepositoryInterface $repository) { try { $repository->delete(); $data = $repository->toArray(); return $this->response->message(trans('messages.success.deleted', ['Module' => trans('green_tag::green_tag_health_benefits.name')])) ->code(202) ->status('success') ->data(compact('data')) ->url(guard_url('green_tag/green_tag_health_benefits/0')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('green_tag/green_tag_health_benefits/' . $repository->getRouteKey())) ->redirect(); } } }