🔴 Laravel Intermediate

What are Form Requests in Laravel?

Why Interviewers Ask This

This question targets practical, hands-on experience with Laravel. Interviewers want to see if you've worked with these concepts in real projects, not just read about them. Strong answers include concrete examples.

Answer

Form Requests are dedicated classes that encapsulate validation and authorization logic, keeping controllers clean. Generate: php artisan make:request StorePostRequest. The class has two methods: authorize() (return true/false — can this user perform this action?) and rules() (return validation rules array). Type-hint the Form Request in your controller method: public function store(StorePostRequest $request) — Laravel automatically validates and authorizes before the method is called. If authorization fails, a 403 response is returned. If validation fails, the user is redirected back with errors. Access validated data with $request->validated() — only returns data that passed validation, never extra fields. Add custom messages with messages() method.

Common Mistake

Don't just define the term — demonstrate that you understand when to use it and when not to. Showing awareness of trade-offs is what separates average from strong Laravel candidates.