Laravel custom validator class adds to the scene

moving from thinkphp to laravel broadens a lot of ideas. I have to say that laravel is really a good product, especially in terms of php project code standards and specifications.
but thinkphp also has some good features, such as verification scenarios, sometimes there are some differences in different business verification fields, for example, the password field must be entered when the user registers, but the password is optional when the user profile is changed. Redefining a validator is wasteful and can be well solved with scenarios.

do verification in laravel. I usually do this

.

1. Generate form request class

php artisan make:request StoreBlogPost

2.StoreBlogPost.php write validation rules

`public function rules ()

{
    return [
        "name"=>"required",
        "email"=>"required|unique:users",
        "password"=>"required|confirmed"
    ];
}
public function message(){

.....
}

`

3. Verify in the controller

    public function store(StoreBlogPost $request)
    {
        $user=User::create([
           "name"=>$request->input("name"),
           "email"=>$request->input("email"),
           "password"=>bcrypt($request->password)
        ]);
        ....
    }

how to add a verification scenario to the validator. A mature extension package is also available.
Please give us some suggestions. Thank you

May.27,2022

it's not clear why you think defining multiple form request classes is a bit wasteful (I've never heard of an extension pack like the TP scenario)
I think you can create multiple FormRequest classes without having to let a form request class take on the responsibility of verifying multiple requests. This makes it clear in terms of readability
for example:
Http\ Requests\ Article\ StoreArticleRequest.php -- form request class for creating articles
Http\ Requests\ Article\ UpdateArticleRequest.php -- updating article content
Http\ Requests\ User\ UpdateUserInfoRequest.php -- updating user information

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b41fd5-2c5df.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b41fd5-2c5df.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?