How validation, authorization and query constraints apply when you retrieve models from input IDs in a Laravel 13 Form Request.
Listen to this pageabout 3 min
When you retrieve Eloquent models from IDs submitted in a form, you can use the Form Request methods model, modelOrFail and models. Building on the requests guide, this page uses the implementation to clarify where these methods stop and input validation and authorization begin.
Retrieve the model after validation
For example, when an authenticated user picks a project of their team by ID, first validate the input format in a Form Request.
namespace App\Http\Requests;use Illuminate\Foundation\Http\FormRequest;class SelectProjectRequest extends FormRequest{ public function authorize(): bool { return $this->user() !== null; } public function rules(): array { return ['project_id' => ['required', 'integer']]; }}
Inject this request into the controller from a route that uses the authentication middleware. This example assumes the application has a Project model and a view policy.
The Form Request is validated before the controller is called. When no matching record exists, modelOrFail throws a ModelNotFoundException, which normal HTTP handling turns into a 404. The team condition narrows the search, but it does not authorize the action on its own. Check the policy after retrieval as well.
These methods read the request input, not validated(). A Form Request’s authorize() runs before validation, so if you call model retrieval inside it, the input has not been validated yet. When you use input in authorize(), treat it as unvalidated and design the validation and authorization you need separately.
Return values and input differences
Method
Input and result
model
Returns null for empty or array input, or when nothing matches. Otherwise returns the first match
modelOrFail
Returns the matching model. Throws ModelNotFoundException when nothing matches
models
Treats the input as an array and returns an Eloquent collection of the matching models
modelOrFail does not treat an array of IDs as the ID of a single model either. models does not throw when some IDs are not found; it returns only the matches. When every ID must exist and be actionable, validate the input array and its elements, compare the results with the input, and authorize each model. Do not assume the results come back in input order.
Query constraints and model inference
Retrieval starts from the model’s query(), so Eloquent global scopes also apply. The closure’s conditions are grouped in a where, and the primary key condition is added after it. This keeps OR conditions from leaking outside the ID condition, even when you use several orWhere calls.When you omit the class, Laravel strips _id / _ids from the input key, infers a singular class name, and looks in the application’s Models namespace, then the root namespace. When the names differ, such as author_id pointing to User, or when you work with a package’s model, pass the class explicitly, such as User::class. The lookup uses the model’s primary key, which is separate from the route key used by route model binding.
{"docsConfig":{"theme":"aspen","$schema":"https://mintlify.com/docs.json","name":"Knowledge of Laravel","colors":{"primary":"#16A34A","light":"#07C983","dark":"#15803D"},"logo":{"light":"https://mintcdn.com/invokable/AuZ0xql2mAbUyZ99/logo/light.svg?fit=max\u0026auto=format\u0026n=AuZ0xql2mAbUyZ99\u0026q=85\u0026s=df0b7397202a6aa1c1f321620c5aa146","dark":"https://mintcdn.com/invokable/AuZ0xql2mAbUyZ99/logo/dark.svg?fit=max\u0026auto=format\u0026n=AuZ0xql2mAbUyZ99\u0026q=85\u0026s=a8a0340d86ff8aa90e9adfc98a0362d7","href":"/"},"favicon":"https://mintcdn.com/invokable/AuZ0xql2mAbUyZ99/favicon.svg?fit=max\u0026auto=format\u0026n=AuZ0xql2mAbUyZ99\u0026q=85\u0026s=8f5a03a681c95d31803fc237b5811065","api":{"playground":{"display":"simple"}},"navbar":{},"footer":{"socials":{"github":"https://github.com/invokable"}},"seo":{"metatags":{"canonical":"https://kawax.biz"},"indexing":"all"},"styling":{"eyebrows":"breadcrumbs","latex":true},"contextual":{"options":["copy","view","chatgpt","claude","perplexity","mcp","cursor","vscode"],"display":"header"},"interaction":{"drilldown":false},"metadata":{"timestamp":true},"navigation":{"languages":[{"language":"jp","default":true,"href":"jp/packages/laravel-boost-copilot-cli"},{"language":"en","href":"en/packages/laravel-boost-copilot-cli"},{"language":"de","href":"de/packages/laravel-boost-copilot-cli"},{"language":"es","href":"es/packages/laravel-boost-copilot-cli"},{"language":"fr","href":"fr/packages/laravel-boost-copilot-cli"},{"language":"it","href":"it/packages/laravel-boost-copilot-cli"},{"language":"ko","href":"ko/packages/laravel-boost-copilot-cli"},{"language":"nl","href":"nl/packages/laravel-boost-copilot-cli"},{"language":"zh-Hans","href":"zh-CN/packages/laravel-boost-copilot-cli"},{"language":"zh-Hant","href":"zh-TW/packages/laravel-boost-copilot-cli"}]}},"deployment":{"deploymentMetadataValue":{"subdomain":"invokable","hasAudioNarration":true,"actualSubdomain":"invokable","customDomains":["kawax.biz"],"gitSource":{"type":"github","owner":"kawax","repo":"mintlify-docs","deployBranch":"main","contentDirectory":"","isPrivate":true,"mountPath":"","label":""},"feedback":{"thumbs":true,"agentFeedback":true},"entitlements":{"AI_CHAT":{"status":"ENABLED"},"WEB_MCP":{"status":"ENABLED"},"NARRATION":{"status":"ENABLED"}},"buildId":"6b0cb20a1ad4e02b275125ce","clientVersion":"0.0.4347","searchFilterCounts":[{"language":"en","tag":"My Packages","count":177},{"language":"jp","tag":"マイパッケージ","count":177},{"language":"de","tag":"Meine Pakete","count":132},{"language":"es","tag":"Mis paquetes","count":132},{"language":"fr","tag":"Mes packages","count":132},{"language":"it","tag":"I miei pacchetti","count":132},{"language":"ko","tag":"My 패키지","count":132},{"language":"nl","tag":"Mijn packages","count":103},{"language":"zh-Hans","tag":"我的包","count":103},{"language":"zh-Hant","tag":"我的套件","count":103},{"language":"de","tag":"Fortgeschrittene Themen","count":94},{"language":"en","tag":"Advanced Topics","count":94},{"language":"es","tag":"Temas avanzados","count":94},{"language":"fr","tag":"Sujets avancés","count":94},{"language":"it","tag":"Argomenti avanzati","count":94},{"language":"jp","tag":"応用トピック","count":94},{"language":"ko","tag":"심화 주제","count":94},{"language":"nl","tag":"Geavanceerde onderwerpen","count":94},{"language":"zh-Hans","tag":"进阶主题","count":94},{"language":"zh-Hant","tag":"進階主題","count":94},{"language":"de","tag":"GitHub Copilot","count":74},{"language":"en","tag":"GitHub Copilot","count":74},{"language":"es","tag":"GitHub Copilot","count":74},{"language":"fr","tag":"GitHub Copilot","count":74},{"language":"it","tag":"GitHub Copilot","count":74},{"language":"jp","tag":"GitHub Copilot","count":74},{"language":"ko","tag":"GitHub Copilot","count":74},{"language":"de","tag":"GitHub Copilot SDK for Laravel","count":72},{"language":"en","tag":"GitHub Copilot SDK for Laravel","count":72},{"language":"es","tag":"GitHub Copilot SDK for Laravel","count":72},{"language":"fr","tag":"GitHub Copilot SDK for Laravel","count":72},{"language":"it","tag":"GitHub Copilot SDK for Laravel","count":72},{"language":"jp","tag":"GitHub Copilot SDK for Laravel","count":72},{"language":"ko","tag":"GitHub Copilot SDK for Laravel","count":72},{"language":"en","tag":"VOICEVOX","count":68},{"language":"jp","tag":"VOICEVOX","count":68},{"language":"de","tag":"Leitfaden","count":61},{"language":"en","tag":"Guide","count":61},{"language":"es","tag":"Guía","count":61},{"language":"fr","tag":"Guide","count":61},{"language":"it","tag":"Guida","count":61},{"language":"jp","tag":"ガイド","count":61},{"language":"ko","tag":"가이드","count":61},{"language":"nl","tag":"Gids","count":61},{"language":"zh-Hans","tag":"指南","count":61},{"language":"zh-Hant","tag":"指南","count":61},{"language":"de","tag":"Blog","count":49},{"language":"en","tag":"Blog","count":49},{"language":"es","tag":"Blog","count":49},{"language":"fr","tag":"Blog","count":49},{"language":"it","tag":"Blog","count":49},{"language":"jp","tag":"ブログ","count":49},{"language":"ko","tag":"블로그","count":49},{"language":"nl","tag":"Blog","count":49},{"language":"zh-Hans","tag":"博客","count":49},{"language":"zh-Hant","tag":"部落格","count":49},{"language":"de","tag":"Paketentwicklung","count":48},{"language":"en","tag":"Package Development","count":48},{"language":"es","tag":"Desarrollo de paquetes","count":48},{"language":"fr","tag":"Développement de packages","count":48},{"language":"it","tag":"Sviluppo di pacchetti","count":48},{"language":"jp","tag":"パッケージ開発","count":48},{"language":"ko","tag":"패키지 개발","count":48},{"language":"nl","tag":"Package-ontwikkeling","count":48},{"language":"zh-Hans","tag":"包开发","count":48},{"language":"zh-Hant","tag":"套件開發","count":48},{"language":"en","tag":"VOICEVOX Engine API Reference","count":45},{"language":"jp","tag":"VOICEVOXエンジンAPIリファレンス","count":45},{"language":"nl","tag":"GitHub Copilot","count":45},{"language":"zh-Hans","tag":"GitHub Copilot","count":45},{"language":"zh-Hant","tag":"GitHub Copilot","count":45},{"language":"nl","tag":"GitHub Copilot SDK for Laravel","count":43},{"language":"zh-Hans","tag":"GitHub Copilot SDK for Laravel","count":43},{"language":"zh-Hant","tag":"GitHub Copilot SDK for Laravel","count":43},{"language":"de","tag":"Tutorial","count":35},{"language":"en","tag":"Tutorial","count":35},{"language":"es","tag":"Tutorial","count":35},{"language":"fr","tag":"Tutoriel","count":35},{"language":"it","tag":"Tutorial","count":35},{"language":"jp","tag":"チュートリアル","count":35},{"language":"ko","tag":"튜토리얼","count":35},{"language":"nl","tag":"Tutorial","count":35},{"language":"zh-Hans","tag":"教程","count":35},{"language":"zh-Hant","tag":"教學","count":35},{"language":"de","tag":"RPC","count":30},{"language":"es","tag":"RPC","count":30},{"language":"fr","tag":"RPC","count":30},{"language":"it","tag":"RPC","count":30},{"language":"ko","tag":"RPC","count":30},{"language":"de","tag":"SDK","count":27},{"language":"es","tag":"SDK","count":27},{"language":"fr","tag":"SDK","count":27},{"language":"it","tag":"SDK","count":27},{"language":"ko","tag":"SDK","count":27},{"language":"nl","tag":"SDK","count":27},{"language":"zh-Hans","tag":"SDK","count":27},{"language":"zh-Hant","tag":"SDK","count":27},{"language":"nl","tag":"VOICEVOX","count":23},{"language":"zh-Hans","tag":"VOICEVOX","count":23},{"language":"zh-Hant","tag":"VOICEVOX","count":23}],"searchSettings":{"isFiltersEnabled":false,"showContentSnippets":true,"fullPageSearch":true}},"assistantConfig":{"enableAskAiButton":false,"enableStarterQuestions":false,"enableContextualStarterQuestions":false,"enableAskAiSearchBar":true},"basePath":"","hasChatPermissions":true,"hasWebMcpPermissions":true,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-rbac-roles","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"rbac-expansion","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"site-roles","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-metadata","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-serve","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"live-agents","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"starter-pricing","enabled":true,"variant":{"name":"treatment","enabled":true,"payload":{"type":"string","value":"treatment"},"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"wildcard-email-auth","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"starterQuestions":[],"privacy":{"consentBanner":{"enabled":true}},"googleFontsInlined":false},"customCss":[]}
{"page":{"pagePath":"en/advanced/form-request-models","slug":"/en/advanced/form-request-models","pageMetadata":{"title":"Form Request model retrieval and input boundaries","description":"How validation, authorization and query constraints apply when you retrieve models from input IDs in a Laravel 13 Form Request.","href":"/en/advanced/form-request-models"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"How validation, authorization and query constraints apply when you retrieve models from input IDs in a Laravel 13 Form Request.\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={a:`a`,code:`code`,li:`li`,p:`p`,pre:`pre`,span:`span`,tbody:`tbody`,td:`td`,th:`th`,thead:`thead`,tr:`tr`,ul:`ul`,..._provideComponents(),...props.components},{CodeBlock,Heading,Table,Warning}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Table)_missingMdxReference(`Table`,true);if(!Warning)_missingMdxReference(`Warning`,true);return _jsxs(_Fragment,{children:[_jsxs(_components.p,{children:[`When you retrieve Eloquent models from IDs submitted in a form, you can use the Form Request methods `,_jsx(_components.code,{children:`model`}),`, `,_jsx(_components.code,{children:`modelOrFail`}),` and `,_jsx(_components.code,{children:`models`}),`. Building on the `,_jsx(_components.a,{href:`/en/requests`,children:`requests guide`}),`, this page uses the implementation to clarify where these methods stop and input validation and authorization begin.`]}),`\n`,_jsx(Heading,{level:`2`,id:`retrieve-the-model-after-validation`,children:`Retrieve the model after validation`}),`\n`,_jsx(_components.p,{children:`For example, when an authenticated user picks a project of their team by ID, first validate the input format in a Form Request.`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`16`,language:`php`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`php`,children:_jsxs(_components.code,{language:`php`,numberOfLines:`16`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`namespace`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` App\\\\Http\\\\Requests`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`use`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#D4D4D4`},children:` Illuminate\\\\Foundation\\\\Http\\\\`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`FormRequest`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`class`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` SelectProjectRequest`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` extends`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:` FormRequest`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` public`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` function`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` authorize`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`()`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`:`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` bool`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` return`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` $this`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`->`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`user`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`() `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`!==`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` null`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` public`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` function`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` rules`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`()`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`:`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` array`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` return`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` [`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'project_id'`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =>`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` [`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'required'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'integer'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`]];`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`Inject this request into the controller from a route that uses the authentication middleware. This example assumes the application has a `,_jsx(_components.code,{children:`Project`}),` model and a `,_jsx(_components.code,{children:`view`}),` policy.`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`17`,language:`php`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`php`,children:_jsxs(_components.code,{language:`php`,numberOfLines:`17`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`use`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#D4D4D4`},children:` App\\\\Http\\\\Requests\\\\`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`SelectProjectRequest`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`use`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#D4D4D4`},children:` App\\\\Models\\\\`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`Project`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`use`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#D4D4D4`},children:` Illuminate\\\\Database\\\\Eloquent\\\\`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`Builder`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`use`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#D4D4D4`},children:` Illuminate\\\\Support\\\\Facades\\\\`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`Gate`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`public`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` function`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` show`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`SelectProjectRequest`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` $request`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` $project`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` $request`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`->`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`modelOrFail`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'project_id'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:` Project`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`::`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`class`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` fn`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`Builder`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` $query`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) => `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`$query`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`->`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`where`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'team_id'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`$request`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`->`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`user`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`()`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`->`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`team_id`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`),`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` );`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:` Gate`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`::`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`authorize`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'view'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`$project`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` return`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` response`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`()`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`->`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`json`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`$project`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`The Form Request is validated before the controller is called. When no matching record exists, `,_jsx(_components.code,{children:`modelOrFail`}),` throws a `,_jsx(_components.code,{children:`ModelNotFoundException`}),`, which normal HTTP handling turns into a 404. The team condition narrows the search, but it does not authorize the action on its own. Check the policy after retrieval as well.`]}),`\n`,_jsx(Warning,{children:_jsxs(_components.p,{children:[`These methods read the request input, not `,_jsx(_components.code,{children:`validated()`}),`. A Form Request’s `,_jsx(_components.code,{children:`authorize()`}),` runs before validation, so if you call model retrieval inside it, the input has not been validated yet. When you use input in `,_jsx(_components.code,{children:`authorize()`}),`, treat it as unvalidated and design the validation and authorization you need separately.`]})}),`\n`,_jsx(Heading,{level:`2`,id:`return-values-and-input-differences`,children:`Return values and input differences`}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Method`}),_jsx(_components.th,{children:`Input and result`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`model`})}),_jsxs(_components.td,{children:[`Returns `,_jsx(_components.code,{children:`null`}),` for empty or array input, or when nothing matches. Otherwise returns the first match`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`modelOrFail`})}),_jsxs(_components.td,{children:[`Returns the matching model. Throws `,_jsx(_components.code,{children:`ModelNotFoundException`}),` when nothing matches`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`models`})}),_jsx(_components.td,{children:`Treats the input as an array and returns an Eloquent collection of the matching models`})]})]})]}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.code,{children:`modelOrFail`}),` does not treat an array of IDs as the ID of a single model either. `,_jsx(_components.code,{children:`models`}),` does not throw when some IDs are not found; it returns only the matches. When every ID must exist and be actionable, validate the input array and its elements, compare the results with the input, and authorize each model. Do not assume the results come back in input order.`]}),`\n`,_jsx(Heading,{level:`2`,id:`query-constraints-and-model-inference`,children:`Query constraints and model inference`}),`\n`,_jsxs(_components.p,{children:[`Retrieval starts from the model’s `,_jsx(_components.code,{children:`query()`}),`, so Eloquent global scopes also apply. The closure’s conditions are grouped in a `,_jsx(_components.code,{children:`where`}),`, and the primary key condition is added after it. This keeps OR conditions from leaking outside the ID condition, even when you use several `,_jsx(_components.code,{children:`orWhere`}),` calls.`]}),`\n`,_jsxs(_components.p,{children:[`When you omit the class, Laravel strips `,_jsx(_components.code,{children:`_id`}),` / `,_jsx(_components.code,{children:`_ids`}),` from the input key, infers a singular class name, and looks in the application’s `,_jsx(_components.code,{children:`Models`}),` namespace, then the root namespace. When the names differ, such as `,_jsx(_components.code,{children:`author_id`}),` pointing to `,_jsx(_components.code,{children:`User`}),`, or when you work with a package’s model, pass the class explicitly, such as `,_jsx(_components.code,{children:`User::class`}),`. The lookup uses the model’s primary key, which is separate from the route key used by route model binding.`]}),`\n`,_jsx(Heading,{level:`2`,id:`related`,children:`Related`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsx(_components.li,{children:_jsx(_components.a,{href:`/en/validation`,children:`Form request validation`})}),`\n`,_jsx(_components.li,{children:_jsx(_components.a,{href:`/en/authorization`,children:`Authorization`})}),`\n`,_jsx(_components.li,{children:_jsx(_components.a,{href:`https://github.com/laravel/docs/blob/13.x/requests.md#retrieving-model-input-values`,children:`Official Laravel requests documentation`})}),`\n`,_jsx(_components.li,{children:_jsx(_components.a,{href:`https://github.com/laravel/framework/blob/v13.44.1/src/Illuminate/Foundation/Http/Concerns/InteractsWithModels.php`,children:`InteractsWithModels implementation (v13.44.1)`})}),`\n`,_jsx(_components.li,{children:_jsx(_components.a,{href:`https://github.com/laravel/framework/blob/v13.44.1/src/Illuminate/Validation/ValidatesWhenResolvedTrait.php`,children:`Form Request validation and authorization order (v13.44.1)`})}),`\n`]})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"Form Request model retrieval and input boundaries","description":"How validation, authorization and query constraints apply when you retrieve models from input IDs in a Laravel 13 Form Request.","href":"/en/advanced/form-request-models"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"Retrieve the model after validation","slug":"retrieve-the-model-after-validation","depth":2,"children":[]},{"title":"Return values and input differences","slug":"return-values-and-input-differences","depth":2,"children":[]},{"title":"Query constraints and model inference","slug":"query-constraints-and-model-inference","depth":2,"children":[]},{"title":"Related","slug":"related","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":[],"narration":{"path":"en/advanced/form-request-models","locale":"en","estimatedDurationSec":166},"subdomain":"invokable","siteName":"Knowledge of Laravel","title":"Form Request model retrieval and input boundaries - Knowledge of Laravel","relatedPagesConfig":{"enabled":true,"limit":5,"mode":"automatic"},"contextualStarterQuestions":[],"navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{"jp":{"href":"/jp/advanced/form-request-models","matchLevel":1},"en":{"href":"/en/advanced/form-request-models","matchLevel":0},"de":{"href":"/de/advanced/form-request-models","matchLevel":1},"es":{"href":"/es/advanced/form-request-models","matchLevel":1},"fr":{"href":"/fr/advanced/form-request-models","matchLevel":1},"it":{"href":"/it/advanced/form-request-models","matchLevel":1},"ko":{"href":"/ko/advanced/form-request-models","matchLevel":1},"nl":{"href":"/nl/advanced/form-request-models","matchLevel":1},"zh-Hans":{"href":"/zh-CN/advanced/form-request-models","matchLevel":1},"zh-Hant":{"href":"/zh-TW/advanced/form-request-models","matchLevel":1}}},"lastModified":"2026-11-29T23:15:31.429Z","gitLastModified":"2026-11-29T23:15:18.000Z","originalFileLocation":"en/advanced/form-request-models.mdx","locale":"en"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"How validation, authorization and query constraints apply when you retrieve models from input IDs in a Laravel 13 Form Request.\">\u003cmeta data-mint-head name=\"application-name\" content=\"Knowledge of Laravel\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/invokable/pboFjibLpJPX3oCo/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/invokable/pboFjibLpJPX3oCo/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/invokable/pboFjibLpJPX3oCo/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/invokable/pboFjibLpJPX3oCo/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/invokable/pboFjibLpJPX3oCo/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/invokable/pboFjibLpJPX3oCo/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/invokable/pboFjibLpJPX3oCo/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/invokable/pboFjibLpJPX3oCo/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/invokable/pboFjibLpJPX3oCo/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Form Request model retrieval and input boundaries - Knowledge of Laravel\">\u003cmeta data-mint-head property=\"og:description\" content=\"How validation, authorization and query constraints apply when you retrieve models from input IDs in a Laravel 13 Form Request.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Knowledge of Laravel\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://kawax.biz/en/advanced/form-request-models\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://invokable.mintlify.site/_mintlify/api/og/v2?division=Laravel+13+New+Features\u0026amp;title=Form+Request+model+retrieval+and+input+boundaries\u0026amp;description=How+validation%2C+authorization+and+query+constraints+apply+when+you+retrieve+models+from+input+IDs+in+a+Laravel+13+Form+Request.\u0026amp;theme=cef70bdc0dd1884481ab7c5d\u0026amp;signature=f91aa39cc058b7684a8b1bd1beb67dadb8861c6e1200dd260c3a6177126d8995\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Form Request model retrieval and input boundaries - Knowledge of Laravel\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"How validation, authorization and query constraints apply when you retrieve models from input IDs in a Laravel 13 Form Request.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://invokable.mintlify.site/_mintlify/api/og/v2?division=Laravel+13+New+Features\u0026amp;title=Form+Request+model+retrieval+and+input+boundaries\u0026amp;description=How+validation%2C+authorization+and+query+constraints+apply+when+you+retrieve+models+from+input+IDs+in+a+Laravel+13+Form+Request.\u0026amp;theme=cef70bdc0dd1884481ab7c5d\u0026amp;signature=f91aa39cc058b7684a8b1bd1beb67dadb8861c6e1200dd260c3a6177126d8995\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/invokable/pboFjibLpJPX3oCo/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Knowledge of Laravel\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#16A34A\">\u003clink data-mint-head rel=\"canonical\" href=\"https://kawax.biz/en/advanced/form-request-models\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/en/advanced/form-request-models.md\">\u003clink data-mint-head rel=\"alternate\" hreflang=\"en\" href=\"https://kawax.biz/en/advanced/form-request-models\">\u003clink data-mint-head rel=\"alternate\" hreflang=\"ja\" href=\"https://kawax.biz/jp/advanced/form-request-models\">\u003clink data-mint-head rel=\"alternate\" hreflang=\"de\" href=\"https://kawax.biz/de/advanced/form-request-models\">\u003clink data-mint-head rel=\"alternate\" hreflang=\"es\" href=\"https://kawax.biz/es/advanced/form-request-models\">\u003clink data-mint-head rel=\"alternate\" hreflang=\"fr\" href=\"https://kawax.biz/fr/advanced/form-request-models\">\u003clink data-mint-head rel=\"alternate\" hreflang=\"it\" href=\"https://kawax.biz/it/advanced/form-request-models\">\u003clink data-mint-head rel=\"alternate\" hreflang=\"ko\" href=\"https://kawax.biz/ko/advanced/form-request-models\">\u003clink data-mint-head rel=\"alternate\" hreflang=\"nl\" href=\"https://kawax.biz/nl/advanced/form-request-models\">\u003clink data-mint-head rel=\"alternate\" hreflang=\"zh-Hans\" href=\"https://kawax.biz/zh-CN/advanced/form-request-models\">\u003clink data-mint-head rel=\"alternate\" hreflang=\"zh-Hant\" href=\"https://kawax.biz/zh-TW/advanced/form-request-models\">\u003clink data-mint-head rel=\"alternate\" hreflang=\"x-default\" href=\"https://kawax.biz/jp/advanced/form-request-models\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://kawax.biz/#organization\",\"name\":\"Knowledge of Laravel\",\"url\":\"https://kawax.biz\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/invokable/AuZ0xql2mAbUyZ99/logo/light.svg?fit=max\u0026auto=format\u0026n=AuZ0xql2mAbUyZ99\u0026q=85\u0026s=df0b7397202a6aa1c1f321620c5aa146\"}},{\"@type\":\"WebSite\",\"@id\":\"https://kawax.biz#website\",\"name\":\"Knowledge of Laravel\",\"url\":\"https://kawax.biz\",\"publisher\":{\"@id\":\"https://kawax.biz/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://kawax.biz/en/advanced/form-request-models#webpage\",\"url\":\"https://kawax.biz/en/advanced/form-request-models\",\"name\":\"Form Request model retrieval and input boundaries\",\"description\":\"How validation, authorization and query constraints apply when you retrieve models from input IDs in a Laravel 13 Form Request.\",\"dateModified\":\"2026-11-29T23:15:18.000Z\",\"isPartOf\":{\"@id\":\"https://kawax.biz#website\"},\"breadcrumb\":{\"@id\":\"https://kawax.biz/en/advanced/form-request-models#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://kawax.biz/en/advanced/form-request-models#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Laravel 13 New Features\",\"item\":\"https://kawax.biz/en/advanced/php-attributes\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Form Request model retrieval and input boundaries\",\"item\":\"https://kawax.biz/en/advanced/form-request-models\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://kawax.biz/en/advanced/form-request-models#article\",\"headline\":\"Form Request model retrieval and input boundaries\",\"name\":\"Form Request model retrieval and input boundaries\",\"description\":\"How validation, authorization and query constraints apply when you retrieve models from input IDs in a Laravel 13 Form Request.\",\"url\":\"https://kawax.biz/en/advanced/form-request-models\",\"mainEntityOfPage\":{\"@id\":\"https://kawax.biz/en/advanced/form-request-models#webpage\"},\"dateModified\":\"2026-11-29T23:15:18.000Z\",\"publisher\":{\"@id\":\"https://kawax.biz/#organization\"},\"isPartOf\":{\"@id\":\"https://kawax.biz#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"Knowledge of Laravel\",\"publisher\":{\"@type\":\"Organization\",\"name\":\"Knowledge of Laravel\"},\"provider\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","agentPointerHref":"/en/advanced/form-request-models.md","siteName":"Knowledge of Laravel","nav":{"global":null,"languages":[{"language":"jp","default":true,"pages":[{"title":"jp","href":"/jp/advanced/form-request-models"}]},{"language":"en","tabs":[{"tab":"My Packages","pages":[{"title":"My Packages","href":"/en/packages/laravel-boost-copilot-cli"}]},{"tab":"Tutorial","pages":[{"title":"Tutorial","href":"/en/introduction"}]},{"tab":"Guide","pages":[{"title":"Guide","href":"/en/lifecycle"}]},{"tab":"Advanced Topics","groups":[{"group":"AI Development","pages":[{"title":"Building an MCP Server with Laravel","href":"/en/advanced/mcp-server"},{"title":"Creating a Custom Agent for Boost","href":"/en/advanced/boost-custom-agent"},{"title":"Creating a Custom Provider for AI SDK","href":"/en/advanced/ai-sdk-custom-provider"},{"title":"Agent Middleware in Laravel AI SDK","href":"/en/advanced/ai-sdk-agent-middleware"}]},{"group":"Design Patterns","pages":[{"title":"The Pipeline Pattern","href":"/en/advanced/pipeline"},{"title":"Fluent Class","href":"/en/advanced/fluent"},{"title":"The Macroable Trait","href":"/en/advanced/macroable"},{"title":"The Conditionable Trait","href":"/en/advanced/conditionable"},{"title":"The InteractsWithTime Trait","href":"/en/advanced/interacts-with-time"},{"title":"The ForwardsCalls trait","href":"/en/advanced/forwards-calls"},{"title":"tap() Helper and the Tappable Trait","href":"/en/advanced/tap"},{"title":"The once() helper internals — Once, Onceable, and PreventsCircularRecursion","href":"/en/advanced/once-helper"},{"title":"The Dumpable Trait","href":"/en/advanced/dumpable"},{"title":"Support Contracts (Arrayable / Jsonable / Htmlable / Responsable)","href":"/en/advanced/support-contracts"},{"title":"The Lottery class","href":"/en/advanced/lottery"},{"title":"Higher Order Messages","href":"/en/advanced/higher-order-messages"},{"title":"Collection Deep Dive","href":"/en/advanced/collection-deep-dive"},{"title":"Illuminate\\Support\\Manager — anatomy of the driver system","href":"/en/advanced/manager"},{"title":"PHP Reflection API","href":"/en/advanced/php-reflection"},{"title":"PHP FFI","href":"/en/advanced/ffi"},{"title":"PHP AST","href":"/en/advanced/php-ast"}]},{"group":"Package Development","pages":[{"title":"Laravel Package Development","href":"/en/advanced/package-development"},{"title":"Package auto-discovery internals","href":"/en/advanced/package-discovery"},{"title":"The InteractsWithData trait","href":"/en/advanced/interacts-with-data"},{"title":"Deferred Service Providers","href":"/en/advanced/deferred-provider"},{"title":"Package Version Compatibility Management","href":"/en/advanced/package-versioning"},{"title":"GitHub Actions Pinning and Security","href":"/en/advanced/github-actions-pinning"},{"title":"Package CHANGELOG and Release Management","href":"/en/advanced/package-changelog"},{"title":"Testing Laravel packages with Orchestra Testbench","href":"/en/advanced/package-testing"},{"title":"Develop Laravel packages with Testbench Workbench","href":"/en/advanced/package-workbench"},{"title":"GeneratorCommand — Implementing custom make: commands","href":"/en/advanced/generator-command"},{"title":"Creating a Laravel Starter Kit","sidebarTitle":"Creating a Starter Kit","href":"/en/advanced/starter-kit-creation"},{"title":"Package Static Analysis (PHPStan / Larastan)","href":"/en/advanced/package-static-analysis"},{"title":"Package config merging and caching","href":"/en/advanced/package-config-merging"},{"title":"Publishing and updating package migrations","href":"/en/advanced/package-migrations"},{"title":"Overriding and updating package views","href":"/en/advanced/package-views"},{"title":"Package route registration and caching","href":"/en/advanced/package-routes"},{"title":"Integrating package caches with optimize","href":"/en/advanced/package-optimization"},{"title":"Package public assets and updates","href":"/en/advanced/package-assets"},{"title":"Package translation overrides and updates","href":"/en/advanced/package-translations"},{"title":"Package service resolution hooks","href":"/en/advanced/package-service-resolution"},{"title":"Adding package diagnostics to about","href":"/en/advanced/package-about"},{"title":"Registering package Artisan commands and resolving dependencies","href":"/en/advanced/package-commands"},{"title":"Registering and caching package event listeners","href":"/en/advanced/package-events"},{"title":"Package service lifetime design","href":"/en/advanced/package-service-lifetimes"},{"title":"Package middleware registration and scope","href":"/en/advanced/package-middleware"},{"title":"Package Blade extensions and the compilation cache","href":"/en/advanced/package-blade-extensions"},{"title":"Registering and re-resolving package Storage drivers","href":"/en/advanced/package-filesystem-drivers"},{"title":"Custom notification channels and delivery testing for packages","href":"/en/advanced/package-notification-channels"},{"title":"Package container tags and plugin aggregation","href":"/en/advanced/package-container-tags"},{"title":"HTTP clients and testing in packages","href":"/en/advanced/package-http-client"},{"title":"Extending and re-resolving log channels in packages","href":"/en/advanced/package-logging"},{"title":"Custom cache stores and contracts in packages","href":"/en/advanced/package-cache-drivers"},{"title":"Registering and testing mail transports in packages","href":"/en/advanced/package-mail-transports"},{"title":"Package contextual attributes and dependency resolution","href":"/en/advanced/package-contextual-attributes"},{"title":"Registering and maintaining scheduled tasks in packages","href":"/en/advanced/package-scheduling"},{"title":"Custom session drivers in packages","href":"/en/advanced/package-session-drivers"},{"title":"Extending database connections in packages","href":"/en/advanced/package-database-connections"},{"title":"Registering dynamic relationships in packages","href":"/en/advanced/package-dynamic-relations"},{"title":"Registering string validation rules in packages","sidebarTitle":"String validation rules","href":"/en/advanced/package-validation-extensions"},{"title":"Package response macros and HTTP contracts","href":"/en/advanced/package-response-macros"},{"title":"Package service decoration and extend","href":"/en/advanced/package-service-decoration"},{"title":"Package policy registration and overrides","href":"/en/advanced/package-authorization"},{"title":"Package morph maps and stored data compatibility","href":"/en/advanced/package-morph-maps"},{"title":"Package queued jobs and upgrade compatibility","href":"/en/advanced/package-queue-jobs"},{"title":"Running external processes in packages and Process::fake","href":"/en/advanced/package-processes"},{"title":"Package Broadcast Channel Authorization and Overrides","href":"/en/advanced/package-broadcasting"},{"title":"Custom UserProviders in Packages","href":"/en/advanced/package-user-providers"},{"title":"Custom Pulse Recorders in Packages","href":"/en/advanced/package-pulse-recorders"}]},{"group":"Application Structure","pages":[{"title":"Application Structure in Laravel 11 and Later","href":"/en/advanced/app-structure"},{"title":"Migration Guide: Old Structure to Slim Application Skeleton","sidebarTitle":"Migration Guide","href":"/en/advanced/app-structure-migration"},{"title":"Laravel 11+ New Application Structure FAQ","sidebarTitle":"New App Structure FAQ","href":"/en/advanced/app-structure-faq"}]},{"group":"Laravel 13 New Features","pages":[{"title":"PHP Attributes","href":"/en/advanced/php-attributes"},{"title":"Controller PHP Attributes","sidebarTitle":"Controller Attributes","href":"/en/advanced/controller-attributes"},{"title":"Handling migration failures with the MigrationFailed event","href":"/en/advanced/migration-failed-event"},{"title":"Measuring migration duration with the MigrationEnded event","href":"/en/advanced/migration-ended-duration"},{"title":"Monitor database transaction duration","href":"/en/advanced/transaction-duration-monitoring"},{"title":"Row locks without blocking foreign key checks with lockForNoKeyUpdate","description":"Learn how Laravel 13.x's lockForNoKeyUpdate works, including PostgreSQL's row-lock mode and the fallback used by other database grammars.","href":"/en/advanced/query-lock-no-key-update"},{"title":"Form Request model retrieval and input boundaries","href":"/en/advanced/form-request-models"}]},{"group":"Eloquent Deep Dive","pages":[{"title":"Eloquent Observers and Model Events","description":"How Eloquent model events work, and how to use Observer classes to handle them in one place. Includes the #[ObservedBy] attribute introduced in Laravel 10 and used throughout Laravel 13.","href":"/en/advanced/eloquent-observers"},{"title":"Eloquent Scopes","href":"/en/advanced/eloquent-scopes"},{"title":"Eloquent Custom Casts","href":"/en/advanced/eloquent-casts"},{"title":"Eloquent Bootable Traits","href":"/en/advanced/eloquent-bootable-traits"},{"title":"Custom pivot models and chaperone","href":"/en/advanced/eloquent-custom-pivot"},{"title":"Eloquent afterQuery and the result contract","sidebarTitle":"afterQuery and result processing","href":"/en/advanced/eloquent-after-query"}]},{"group":"Validation Extensions","pages":[{"title":"Custom Validation Rules","href":"/en/advanced/custom-validation-rules"}]},{"group":"Authentication Extensions","pages":[{"title":"Custom Authentication Guards","href":"/en/advanced/custom-auth-guard"},{"title":"Laravel Fortify and Starter Kits","href":"/en/advanced/fortify"},{"title":"Creating a Custom Hash Driver","href":"/en/advanced/custom-hash-driver"}]},{"group":"Security","pages":[{"title":"Rate Limiting","href":"/en/advanced/rate-limiting"}]},{"group":"Queues","pages":[{"title":"Queue Job Execution Control","href":"/en/advanced/queue-job-control"},{"title":"Queue job retry policies","href":"/en/advanced/queue-retry-policy"}]},{"group":"Testing","pages":[{"title":"Advanced Testing with Pest","href":"/en/advanced/testing-pest"}]},{"group":"Realtime","pages":[{"title":"Inside the Mercure broadcast driver","href":"/en/advanced/mercure-broadcasting"}]}]},{"tab":"Blog","pages":[{"title":"Blog","href":"/en/blog/changelog/202610"}]}]},{"language":"de","pages":[{"title":"de","href":"/de/advanced/form-request-models"}]},{"language":"es","pages":[{"title":"es","href":"/es/advanced/form-request-models"}]},{"language":"fr","pages":[{"title":"fr","href":"/fr/advanced/form-request-models"}]},{"language":"it","pages":[{"title":"it","href":"/it/advanced/form-request-models"}]},{"language":"ko","pages":[{"title":"ko","href":"/ko/advanced/form-request-models"}]},{"language":"nl","pages":[{"title":"nl","href":"/nl/advanced/form-request-models"}]},{"language":"zh-Hans","pages":[{"title":"zh-Hans","href":"/zh-CN/advanced/form-request-models"}]},{"language":"zh-Hant","pages":[{"title":"zh-Hant","href":"/zh-TW/advanced/form-request-models"}]}]},"basePath":"","title":"Form Request model retrieval and input boundaries - Knowledge of Laravel","deploymentId":"dpl_6UE2cqB47X6P7P3F2hD3UphW6ijc","buildId":"dpl_6UE2cqB47X6P7P3F2hD3UphW6ijc","dynamics":["2bfc744e19"],"chunks":["NarrationPlayer-C5M_mUsK.js","types-CiTgMxws.js","shallow-DapBSR9G.js"]}