Skip to main content

The Request object

Illuminate\Http\Request provides an object-oriented interface for working with the current HTTP request. Through it you can access form data, query strings, uploaded files, headers, and more.

Injecting the request into controllers

Type-hint Illuminate\Http\Request in a controller method and Laravel’s service container injects the current request instance automatically:
Route closures work the same way:

Using route parameters alongside the request

When a controller method also needs a route parameter, list the Request type-hint first, then the route parameters:

Retrieving input

All input

Use all() to retrieve all input as an array. It works for both HTML forms and XHR requests:

A specific field

input() retrieves a value from the entire request payload, including the query string, regardless of the HTTP method:
Supply a default value as the second argument:
Access nested array input with dot notation:

Query string only

query() retrieves values exclusively from the query string:
input() searches both the request body and the query string, while query() only searches the query string. Use query() when you need to distinguish between POST data and URL parameters.

Typed retrieval

Laravel provides helpers to retrieve input already cast to a specific type:

Dynamic properties

You can access input values as properties directly on the request object:
Dynamic properties first search the request payload, then fall back to route parameters if nothing is found.

Subsets of input

Use only() and except() to retrieve a subset of input:

Checking for input

Use has() to determine whether a value is present in the request:
Use filled() to check that a value is present and not empty:
Use isNotFilled() when the value is absent or empty:

Inspecting the request

Path and URL

HTTP method

File uploads

Retrieving an uploaded file

Use file() to retrieve an Illuminate\Http\UploadedFile instance:
Check that a file was actually uploaded with hasFile():

Storing the file

Use store() to save the file to a storage disk. The filename is generated automatically:
To specify a filename, use storeAs():
Always validate the file type and size when accepting uploads. Use Laravel’s validation rules to handle this safely.

Example: handling a registration form

Define the corresponding route:

Next steps

Responses

Learn how to return views, redirects, and JSON from your controllers.
Last modified on July 13, 2026