LaravelForm Request(s)


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.