lundi 19 avril 2021

Laravel 5.7 validation makes nothing

My function works by itself but the validation is not executed. Does anyone know what I forgot to add?

This is a snippet of my code:

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)
    {
      $request->validate([
    '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');
    }

Thanks in advance



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

Aucun commentaire:

Enregistrer un commentaire