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