Laravel

Request parameters

Reading request data through Laravel's typed helpers does two things during analysis: the call's return value gets the right type, and the accessed field is recorded in your API documentation.

Fields read on routes that accept GET requests become documented query parameters. On other routes they are added to the request body.

Typed helpers

These helper methods are recognized on $request and on the request() helper:

array, boolean, collect, date, enum, enums, float, input, integer, str, string

request()->string('name');                     // string
request()->integer('per_page');                // integer
request()->boolean('active');                  // boolean
request()->float('price');                     // number
request()->date('from');                       // string, date format
request()->enum('state', StateEnum::class);    // StateEnum values
request()->enums('states', StateEnum::class);  // array of StateEnum values
request()->array(['name', 'active']);          // object with the listed fields
request()->collect('tags');                    // collection

enum and enums resolve the allowed values from the enum class passed as the second argument. Passing a key list to array([...]) or collect([...]) expands every listed key into its own documented field.

Dot notation

Field names follow Laravel's data_get semantics. Dots produce nested objects, * segments produce arrays of objects, and separate calls that share a parent key merge into one shape:

request()->string('user.name');
request()->integer('user.age');
request()->boolean('items.*.active');
request()->array(['address.city', 'address.zip']);

The documented request body:

{
    user?: {
        name?: string
        age?: number
    }
    items?: {
        active?: boolean
    }[]
    address?: {
        city?: string
        zip?: string
    }
}

Escaped dots (\.) are treated as literal characters in the key.

Headers

request()->header('X-Custom-Header') records X-Custom-Header as a documented header parameter. The return value is typed string | array | null when a key is given, and as the full header map when called without arguments.

Query strings

request()->query('token') records token as a documented query parameter, regardless of the route's HTTP method. Like header, the return value is typed string | array | null for a single key and as the full query map without arguments.