Laravel

Request & Response

Request object, input handling, file uploads, response types, redirects, JSON responses, cookies, sessions

20 pytań z rozmów·
Junior
1

Which method of the Request object allows retrieving the value of a form field?

Odpowiedź

The input() method of the Request object allows retrieving data sent via GET, POST, or any other HTTP method. It accepts a field name as a parameter and returns its value, or null if the field does not exist. A default value can be passed as a second parameter to avoid null values.

2

Which method allows checking if a specific field is present in the request?

Odpowiedź

The has() method checks if one or more fields are present in the request and contain a non-empty value. It returns a boolean. To simply check for field presence even if empty, use filled() which checks the field exists AND is not empty, or exists() to only check presence without validating the value.

3

Which method allows retrieving all request fields as an array?

Odpowiedź

The all() method returns all request data as an associative array. Unlike only() which filters specific fields, or except() which excludes certain fields, all() returns all submitted data. This method is useful for passing all data to validation or for global processing.

4

How to retrieve only specific fields from a request?

5

How to retrieve an uploaded file from an HTTP request?

+17 pytań z rozmów

Opanuj Laravel na następną rozmowę

Uzyskaj dostęp do wszystkich pytań, flashcards, testów technicznych, ćwiczeń code review i symulatorów rozmów.

Zacznij za darmo