jeudi 29 octobre 2020

laravel validation does not work with Auth

I am trying to add validation in the controller but it does not work with auth:check. This is the Laravel version 5.7.

This is the function store that has a problem with the validation.

 public function store(Request $request)
    {
        $request->validate([
                'first_name' => ['required'|'min:2'|'max:50']
                ]);
        
        if(Auth::check()){
            
            $player = Player::create([
                'first_name' => $request->input('fist_name'),
                'last_name' => $request->input('last_name'),
            ]);
 
 
            if($player){
                return redirect()->route('players.show', ['player'=> $player->id])
                ->with('success' , 'foo');
            }
 
        }
         
        return back()->withInput()->with('errors', 'Foo Error');
    }


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire