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