Problems with laravel form validation

when you first transfer from thinkphp5.1 to laravel, for form validation, there are two ways to look at the document:

the first is to use the following code directly in the controller

$this->validte(request(),$rule)

the second is

Validate::make(request()->all(),$rule);

but there is a difference between the two. The first one can keep the page on the submission page after the validation error is found, and the error message can be displayed directly through the following code

@if(count($errors)>0)
    <div class="alert alert-danger" role="alert">
        @foreach($errors->all() as $error)
            <li>{{$error}}</li>
        @endforeach
    </div>
@endif

clipboard.png
but the second goes directly to the form submission method, and the page jumps.

because I need it, I rewrite the verification layer, but I don"t want to inherit the Controller class. I use the following method to handle validation:

class Validate
{
    protected $rule=[];
    protected $message=[];
    protected $sence=[];

    protected $input;
    private $validator;

   final public function check($input,$senceName=null){
       $this->input=$input;
       .....
       $this->validator=Validator::make($input,$rule,$message);
        /*,*/
        if($this->validator->fails()){
            return back()->withErrors($this->validator)
                ->withInput();
        }
        return true;
    }

the problem mainly lies in the code where the verification failed, how to achieve the effect of the first kind of verification, and how my code needs to be modified.

there is another problem. Just transferred from the tp framework, I used to find a method in a class that can be found directly with the ctrl+ left button in phpstorm.
but I can never find this method in laravel. For example, the valiate function in the first controller base class, how can I find the source code of this function? how can laravel find the corresponding function quickly?

ask for your advice, thank you very much

Jan.10,2022

there is another @ _ @ that can also implement the first.

php artisan make:request TestRequest

generates a Request under the app/Http/Requests directory that needs to change the default false of the return value in the authorize method to true, and then override the error information in the rule messages method in the rules method.

then change the default injected Request to the self-written Request when the controller invokes.

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-1e52199-45197.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-1e52199-45197.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?