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