Laravel Form Request(s)

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Introduction

Custom requests (or Form Requests) are useful in situations when one wants to authorize & validate a request before hitting the controller method.

One may think of two practical uses, creating & updating a record while each action has a different set of validation (or authorization) rules.

Using Form Requests is trivial, one has to type-hint the request class in method.

Syntax

  • php artisan make:request name_of_request

Remarks

Requests are useful when separating your validation from Controller. It also allows you to check if the request is authorized.



Got any Laravel Question?