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