This is what we usually do in a controller to validate a request:
$validated = $request->validate([
'title' => 'required|unique:posts|max:255',
'body' => 'required',
]);
Since the validate() method is not accessible in a Laravel middleware we should use facade for validating a request inside the middleware.
use Illuminate\Support\Facades\Validator;
and then :
$validator = Validator::make($request->all(), [
'title' => 'required|unique:posts|max:255',
'body' => 'required',
]);
I would like to introduce two packages for Laravel that I have recently developed: Laravel Pay Pocket, a modern multi-wallet package, and Laravel Failed Jobs, a UI for the Laravel Failed Jobs Table. I hope they may be of help to you.
https://github.com/HPWebdeveloper/laravel-pay-pocket
https://github.com/HPWebdeveloper/laravel-failed-jobs