3:I[5613,[],""] 4:I[1778,[],""] 5:I[2266,["250","static/chunks/250-e45a0a9f1f87fcb8.js","123","static/chunks/123-437e492929b8e5cd.js","787","static/chunks/787-34619535dc4c8b8e.js","185","static/chunks/app/layout-8e510c4a6ad04f5a.js"],"Providers"] 6:I[6080,["250","static/chunks/250-e45a0a9f1f87fcb8.js","123","static/chunks/123-437e492929b8e5cd.js","787","static/chunks/787-34619535dc4c8b8e.js","185","static/chunks/app/layout-8e510c4a6ad04f5a.js"],"Layout"] 7:I[5250,["250","static/chunks/250-e45a0a9f1f87fcb8.js","123","static/chunks/123-437e492929b8e5cd.js","159","static/chunks/app/docs/guide/request/page-6d0103cf4c07578d.js"],""] 0:["eLuBIjOTKDjvNSEcdbrLy",[[["",{"children":["docs",{"children":["guide",{"children":["request",{"children":["__PAGE__",{}]}]}]}]},"$undefined","$undefined",true],["",{"children":["docs",{"children":["guide",{"children":["request",{"children":["__PAGE__",{},["$L1","$L2",null]]},["$","$L3",null,{"parallelRouterKey":"children","segmentPath":["children","docs","children","guide","children","request","children"],"loading":"$undefined","loadingStyles":"$undefined","loadingScripts":"$undefined","hasLoading":false,"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L4",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":"$undefined","notFoundStyles":"$undefined","styles":null}]]},["$","$L3",null,{"parallelRouterKey":"children","segmentPath":["children","docs","children","guide","children"],"loading":"$undefined","loadingStyles":"$undefined","loadingScripts":"$undefined","hasLoading":false,"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L4",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":"$undefined","notFoundStyles":"$undefined","styles":null}]]},["$","$L3",null,{"parallelRouterKey":"children","segmentPath":["children","docs","children"],"loading":"$undefined","loadingStyles":"$undefined","loadingScripts":"$undefined","hasLoading":false,"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L4",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":"$undefined","notFoundStyles":"$undefined","styles":null}]]},[null,["$","html",null,{"lang":"en","className":"h-full antialiased __variable_aaf875 __variable_b436a8","suppressHydrationWarning":true,"children":["$","body",null,{"className":"flex min-h-full bg-white dark:bg-slate-900","children":["$","$L5",null,{"children":["$","$L6",null,{"children":["$","$L3",null,{"parallelRouterKey":"children","segmentPath":["children"],"loading":"$undefined","loadingStyles":"$undefined","loadingScripts":"$undefined","hasLoading":false,"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L4",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":["$","div",null,{"className":"min-w-0 max-w-2xl flex-auto px-4 py-16 lg:max-w-none lg:pl-8 lg:pr-0 xl:px-16","children":["$","div",null,{"className":"flex h-full flex-col items-center justify-center text-center","children":[["$","p",null,{"className":"font-display text-sm font-medium text-slate-900 dark:text-white","children":"404"}],["$","h1",null,{"className":"mt-3 font-display text-3xl tracking-tight text-slate-900 dark:text-white","children":"Page not found"}],["$","p",null,{"className":"mt-2 text-sm text-slate-500 dark:text-slate-400","children":"Sorry, we couldn’t find the page you’re looking for."}],["$","$L7",null,{"href":"/","className":"mt-8 text-sm font-medium text-slate-900 dark:text-white","children":"Go back home"}]]}]}],"notFoundStyles":[],"styles":null}]}]}]}]}],null]],[[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/ecb0509aa3fc3a51.css","precedence":"next","crossOrigin":""}]],"$L8"]]]] 9:I[4841,["250","static/chunks/250-e45a0a9f1f87fcb8.js","123","static/chunks/123-437e492929b8e5cd.js","159","static/chunks/app/docs/guide/request/page-6d0103cf4c07578d.js"],"DocsHeader"] a:I[659,["250","static/chunks/250-e45a0a9f1f87fcb8.js","123","static/chunks/123-437e492929b8e5cd.js","159","static/chunks/app/docs/guide/request/page-6d0103cf4c07578d.js"],"Fence"] b:I[5357,["250","static/chunks/250-e45a0a9f1f87fcb8.js","123","static/chunks/123-437e492929b8e5cd.js","159","static/chunks/app/docs/guide/request/page-6d0103cf4c07578d.js"],"PrevNextLinks"] 2:["$","div",null,{"className":"min-w-0 max-w-2xl flex-auto px-4 py-16 lg:max-w-none lg:pl-8 lg:pr-0 xl:px-16","children":[["$","article",null,{"children":[["$","$L9",null,{"title":"Request & Response"}],["$","div",null,{"className":"prose prose-slate max-w-none dark:prose-invert dark:text-slate-400 prose-headings:scroll-mt-28 prose-headings:font-display prose-headings:font-normal lg:prose-headings:scroll-mt-[8.5rem] prose-lead:text-slate-500 dark:prose-lead:text-slate-400 prose-a:font-semibold dark:prose-a:text-sky-400 prose-a:no-underline prose-a:shadow-[inset_0_-2px_0_0_var(--tw-prose-background,#fff),inset_0_calc(-1*(var(--tw-prose-underline-size,4px)+2px))_0_0_var(--tw-prose-underline,theme(colors.sky.300))] hover:prose-a:[--tw-prose-underline-size:6px] dark:[--tw-prose-background:theme(colors.slate.900)] dark:prose-a:shadow-[inset_0_calc(-1*var(--tw-prose-underline-size,2px))_0_0_var(--tw-prose-underline,theme(colors.sky.800))] dark:hover:prose-a:[--tw-prose-underline-size:6px] prose-pre:rounded-xl prose-pre:bg-slate-900 prose-pre:shadow-lg dark:prose-pre:bg-slate-800/60 dark:prose-pre:shadow-none dark:prose-pre:ring-1 dark:prose-pre:ring-slate-300/10 dark:prose-hr:border-slate-800","children":[["$","h2",null,{"id":"request","children":"Request"}],["$","h3",null,{"id":"reading-parameters","children":"Reading parameters"}],["$","$La",null,{"language":"php","children":"function index(Request $request) \n{\n $page = $request['page'];\n /* return 1 if page parameter not exist */\n $page = $request->getParemter('page', 1);\n}\n\n"}],["$","h3",null,{"id":"validation","children":"Validation"}],["$","$La",null,{"language":"php","children":"#[Controller]\n#[Route(\"/admin/users\")]\nreadonly class UserController\n{\n function add(Request $request) \n {\n $rules = [\n 'name' => ['required', 'unique_username'],\n 'first_name' => ['required'],\n 'last_name' => ['required'],\n 'email' => ['required', 'email'],\n 'role' => ['required', 'option' => ['reader','editor']],\n 'password' => ['required'],\n 'password2' => ['required', 'repeated_password']];\n $result = $request->validate($rules);\n if ($request->isPost() and $result->isValid()) {\n $fields = ['firstName' => 'first-name', 'username', 'email'];\n $user = $request->toObject($fields);\n }\n }\n}\n"}],["$","h4",null,{"id":"build-in-validators","children":"build in validators"}],["$","ul",null,{"children":[["$","li",null,{"children":"required"}],["$","li",null,{"children":"email"}],["$","li",null,{"children":"option"}],["$","li",null,{"children":"min (refers to string and numeric)"}],["$","li",null,{"children":"max (as before)"}],["$","li",null,{"children":"checked"}],["$","li",null,{"children":"unchecked"}],["$","li",null,{"children":"range"}],["$","li",null,{"children":"number (check is numeric)"}],["$","li",null,{"children":"alpha (alphabetic characters)"}],["$","li",null,{"children":"alpha_num (alphabetic-numeric characters)"}]]}],["$","h4",null,{"id":"custom-validators","children":"custom validators"}],["$","p",null,{"children":["To make own validator implement ",["$","code",null,{"children":"IValidator"}]," interface and add ",["$","code",null,{"children":"Validator"}]," sufix to your class."]}],["$","$La",null,{"language":"php","children":"class RepeatedPasswordValidator implements IValidator\n{\n public function __construct(/* your components to inject if required */) { }\n \n function validate(mixed $value, string $name, array $data, array $args): ValidatorResult\n {\n if (!empty($data['password']) && ($data['password'] !== $data['password2']))\n return new ValidatorResult(false, _(\"Passwords should be the same\"));\n return new ValidatorResult();\n }\n}\n"}],["$","$La",null,{"language":"php","children":"$$form->rules = [\n //add by convention\n 'password2' => ['repeated_password'] \n //add by fully qualified name\n 'password2' => [RepeatedPasswordValidator::class]\n];\n"}],["$","h3",null,{"id":"assigning-data","children":"Assigning data"}],["$","$La",null,{"language":"php","children":"$$user = $this->userStorage->load();\n/* Assigning all fields with object */\n$this->request->assign($user);\n/* Assigning fields given by map */\n$fieldsMap = ['first-name' => 'firstName', 'username', 'email'];\n$this->request->assign($user, $fieldsMap);\n"}],["$","h4",null,{"id":"to-new-object","children":"to new object"}],["$","$La",null,{"language":"php","children":"/* Converts all fields */\n$user = $this->request->toObject();\n/* Converts fields given by map */\n$fieldsMap = ['first-name' => 'firstName', 'username', 'email'];\n$user = $this->request->toObject($fieldsMap)\n"}],["$","h3",null,{"id":"file-upload","children":"File upload"}],["$","$La",null,{"language":"php","children":"#[Route('/upload')]\npublic function upload(): View\n{\n $directory = 'your_directory'\n if ($this->request->isPost()) {\n $file = $this->request->getFile('file');\n if ($file?->isUploaded()) {\n $file->move($directory);\n }\n }\n return view(\"@frontend/upload\");\n}\n"}],["$","h5",null,{"id":"options","children":"options"}],["$","p",null,{"children":["To prevent collision and overwriting file change name manually or generate unique name."," ","Function generate name and check it exists until can be saved without overwriting."]}],["$","$La",null,{"language":"php","children":"$$options = {\n 'filename' => 'your unique filename'\n}\n$options = { \n 'gen-unique-filename' => true,\n 'gen-filename-len' => 78 // by default 64. Optional\n}\n$file->move($directory, $options);\nsave_name_to_db($file->name);\n"}],["$","h2",null,{"id":"response","children":"Response"}],["$","h3",null,{"id":"cookies","children":"Cookies"}],["$","$La",null,{"language":"php","children":"#[Controller]\nreadonly class AuthenticationController\n{\n #[Route(\"/authenticate\")]\n function authenticate(Response $response) \n {\n $response->setCookie('your_cookie_name', 'encrypted_user_data');\n return view('homepage');\n }\n}\n"}],["$","h3",null,{"id":"header","children":"Header"}],["$","$La",null,{"language":"php","children":"#[Controller]\nreadonly class AuthenticationController\n{\n #[Route(\"/authenticate\")]\n function authenticate(Response $response) \n {\n $response->addHeader('x-header-name', 'header-value');\n return view('homepage');\n }\n}\n"}],["$","h3",null,{"id":"redirect-messages","children":"Redirect messages"}],["$","$La",null,{"language":"php","children":"#[Controller]\nreadonly class AuthenticationController\n{\n #[Route(\"/authenticate\")]\n function authenticate(Response $response) \n {\n // set only message name\n $response->setRedirectMessage('authenticated');\n // set message name and value\n $response->setRedirectMessage('authenticated', 'User authenticated successfully');\n return redirect('homepage');\n }\n}\n"}],["$","h2",null,{"id":"redirect-messages-2","children":"Redirect messages"}],["$","p",null,{"children":["Allows to keep message between redirects. It's good to implement success or failure messages about user actions."," ","Deleted after reading or checked if is set (behaviour similar to flag)."]}],["$","h4",null,{"id":"using-redirect-function","children":"Using redirect function"}],["$","$La",null,{"language":"php","children":"#[Controller]\nreadonly class AuthenticationController\n{\n #[Route(\"/authenticate\")]\n function authenticate(Response $response) \n {\n //redirect and set message name\n $result = redirect('homepage', 'authenticated');\n //redirect, set message name and value\n $result = redirect('homepage', 'authenticated', 'User authenticated successfully');\n \n return $result;\n }\n}\n"}],["$","h4",null,{"id":"displaying-message","children":"Displaying message"}],["$","$La",null,{"language":"html","children":"@if (has_redirect_message('success'))\n