beginnerLaravel
Previous
What is the difference between global and route middleware?
Next
What is dependency injection in a controller method?
How do you retrieve request data in Laravel?
Answer
Clear, interview-ready explanation
Controller actions and route closures can type-hint Illuminate\Http\Request to receive the current request. Common methods include input('name'), query('page'), all(), only([...]), except([...]), has('field'), filled('field'), and boolean('active').
Use a narrow retrieval method whenever possible instead of passing all request input through the application. After validation, use validated() or safe() to work with approved data rather than raw request data, especially before mass assignment or business operations.