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');
    }


from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2Ja0CDq
via IFTTT

Aucun commentaire:

Enregistrer un commentaire