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