repository = $faqcategory; $this->repository ->pushCriteria(\Litepie\Repository\Criteria\RequestCriteria::class) ->pushCriteria(\Litecms\Faqcategory\Repositories\Criteria\FaqcategoryResourceCriteria::class); } /** * Display a list of faqcategory. * * @return Response */ public function index(FaqcategoryRequest $request) { $view = $this->response->theme->listView(); if ($this->response->typeIs('json')) { $function = camel_case('get-' . $view); return $this->repository ->setPresenter(\Litecms\Faqcategory\Repositories\Presenter\FaqcategoryPresenter::class) ->$function(); } $faqcategories = $this->repository->paginate(); return $this->response->title(trans('faqcategory::faqcategory.names')) ->view('faqcategory::faqcategory.index', true) ->data(compact('faqcategories')) ->output(); } /** * Display faqcategory. * * @param Request $request * @param Model $faqcategory * * @return Response */ public function show(FaqcategoryRequest $request, Faqcategory $faqcategory) { if ($faqcategory->exists) { $view = 'faqcategory::faqcategory.show'; } else { $view = 'faqcategory::faqcategory.new'; } return $this->response->title(trans('app.view') . ' ' . trans('faqcategory::faqcategory.name')) ->data(compact('faqcategory')) ->view($view, true) ->output(); } /** * Show the form for creating a new faqcategory. * * @param Request $request * * @return Response */ public function create(FaqcategoryRequest $request) { $faqcategory = $this->repository->newInstance([]); return $this->response->title(trans('app.new') . ' ' . trans('faqcategory::faqcategory.name')) ->view('faqcategory::faqcategory.create', true) ->data(compact('faqcategory')) ->output(); } /** * Create new faqcategory. * * @param Request $request * * @return Response */ public function store(FaqcategoryRequest $request) { try { $attributes = $request->all(); $attributes['user_id'] = user_id(); $attributes['user_type'] = user_type(); $faqcategory = $this->repository->create($attributes); return $this->response->message(trans('messages.success.created', ['Module' => trans('faqcategory::faqcategory.name')])) ->code(204) ->status('success') ->url(guard_url('faqcategory/faqcategory/' . $faqcategory->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('/faqcategory/faqcategory')) ->redirect(); } } /** * Show faqcategory for editing. * * @param Request $request * @param Model $faqcategory * * @return Response */ public function edit(FaqcategoryRequest $request, Faqcategory $faqcategory) { return $this->response->title(trans('app.edit') . ' ' . trans('faqcategory::faqcategory.name')) ->view('faqcategory::faqcategory.edit', true) ->data(compact('faqcategory')) ->output(); } /** * Update the faqcategory. * * @param Request $request * @param Model $faqcategory * * @return Response */ public function update(FaqcategoryRequest $request, Faqcategory $faqcategory) { try { $attributes = $request->all(); $faqcategory->update($attributes); return $this->response->message(trans('messages.success.updated', ['Module' => trans('faqcategory::faqcategory.name')])) ->code(204) ->status('success') ->url(guard_url('faqcategory/faqcategory/' . $faqcategory->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('faqcategory/faqcategory/' . $faqcategory->getRouteKey())) ->redirect(); } } /** * Remove the faqcategory. * * @param Model $faqcategory * * @return Response */ public function destroy(FaqcategoryRequest $request, Faqcategory $faqcategory) { try { $faqcategory->delete(); return $this->response->message(trans('messages.success.deleted', ['Module' => trans('faqcategory::faqcategory.name')])) ->code(202) ->status('success') ->url(guard_url('faqcategory/faqcategory/0')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('faqcategory/faqcategory/' . $faqcategory->getRouteKey())) ->redirect(); } } /** * Remove multiple faqcategory. * * @param Model $faqcategory * * @return Response */ public function delete(FaqcategoryRequest $request, $type) { try { $ids = hashids_decode($request->input('ids')); if ($type == 'purge') { $this->repository->purge($ids); } else { $this->repository->delete($ids); } return $this->response->message(trans('messages.success.deleted', ['Module' => trans('faqcategory::faqcategory.name')])) ->status("success") ->code(202) ->url(guard_url('faqcategory/faqcategory')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->status("error") ->code(400) ->url(guard_url('/faqcategory/faqcategory')) ->redirect(); } } /** * Restore deleted faqcategories. * * @param Model $faqcategory * * @return Response */ public function restore(FaqcategoryRequest $request) { try { $ids = hashids_decode($request->input('ids')); $this->repository->restore($ids); return $this->response->message(trans('messages.success.restore', ['Module' => trans('faqcategory::faqcategory.name')])) ->status("success") ->code(202) ->url(guard_url('/faqcategory/faqcategory')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->status("error") ->code(400) ->url(guard_url('/faqcategory/faqcategory/')) ->redirect(); } } }