user(); $data = $request->getDto(); $querySettingsDto = new QuerySettingsDto( limit: 20, page: $data->getPage(), queryWith: [] ); $result = $this->captchaTokenService->index($data->getCaptchaTokenDto(), $querySettingsDto, $user); if ($result->isError()) { $this->errors($result); } return view('private/captcha_tokens/index', $result->getData()); } public function create(Request $request): View { $user = $request->user(); $result = $this->captchaTokenService->create($user); if ($result->isError()) { $this->errors($result); } return view('private/captcha_tokens/create', $result->getData()); } public function edit(int $id, Request $request): View { $user = $request->user(); $result = $this->captchaTokenService->edit($id, $user); if ($result->isError()) { $this->errors($result); } return view('private/captcha_tokens/edit', $result->getData()); } public function store(StoreUpdateRequest $request): RedirectResponse { $data = $request->getDto(); $user = $request->user(); $result = $this->captchaTokenService->store($data, $user); if ($result->isError()) { return redirect()->back()->withInput()->withErrors($result->getErrorsOrMessage()); } return redirect()->route('captcha-tokens.edit', $result->getModel())->withSuccess($result->getMessage()); } public function update(int $id, StoreUpdateRequest $request): RedirectResponse { $data = $request->getDto(); $user = $request->user(); $result = $this->captchaTokenService->update($id, $data, $user); if ($result->isError()) { return redirect()->back()->withInput()->withErrors($result->getErrorsOrMessage()); } return redirect()->route('captcha-tokens.edit', $result->getModel())->withSuccess($result->getMessage()); } public function destroy(int $id, Request $request): RedirectResponse { $user = $request->user(); $result = $this->captchaTokenService->destroy($id, $user); if ($result->isError()) { return redirect()->back()->withInput()->withErrors($result->getErrorsOrMessage()); } return redirect()->route('captcha-tokens.index')->withSuccess($result->getMessage()); } }