@denis
In Laravel, you can make a request by creating a new Request class using artisan command. Here's how you can make a request in Laravel:
1
|
php artisan make:request MyRequest |
Replace MyRequest
with the desired name of your Request class.
1 2 3 4 5 6 7 |
public function rules() { return [ 'name' => 'required|string|max:255', 'email' => 'required|email|unique:users,email', ]; } |
1 2 3 4 5 6 |
use AppHttpRequestsMyRequest; public function store(MyRequest $request) { // Your logic here } |
The incoming request data will automatically be validated against the rules defined in the MyRequest
class, and if the validation fails, Laravel will throw a ValidationException
with the errors.