Laravel 5.7 验证什么都不做

Laravel 5.7 validation makes nothing

我的函数自行运行,但未执行验证。有谁知道我忘了添加什么?

这是我的代码片段:

namespace App\Http\Controllers;

use App\Player;
use App\Tournament;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Auth;


    public function store(Request $request)
    {
       $data=$request->all();
$validator = Validator::make($data, [
            'first_name' => 'alpha|min:2|max:30',
        ]);
        
        
        
        if(Auth::check()){

            $foo = Foo::create([
                'first_name' => $request->input('fist_name'),
                'last_name' => $request->input('last_name'),
            ]);
 
            if($foo){
                return redirect()->route('foo.show', ['foo'=> $foo->id])
                ->with('success' , 'Foo created!');
            }
 
        }
         
        return back()->withInput()->with('errors', 'Error when creating the foo');
    }

提前致谢

尝试不同的方法,例如:

use Illuminate\Support\Facades\Validator;

...
$data=$request->all();
$validator = Validator::make($data, [
            'first_name' => 'alpha|min:2|max:30',,  
        ]);
    public function store(Request $request)
    {
        $validator = Validator::make($request->all(), [
            'category' => 'required',
        ]);

        //validating input

        if ($validator->fails()) {
            return back()->with('toast_error', $validator->messages()->all()[0])->withInput();
        }
// more code to run when if statement is executed with true for validated data
    }