mardi 31 juillet 2018

Laravel Errors field is required

hi i have a problem that the error message is not showing the field name and its only showing the errorfor the first field not for all the fields

here is the code

 public function store(Request $request)
{
    //validate
    $this->validate($request,[
       $request->name=>'required',
       $request->type=>'required',
       $request->color=>'required',
        $request->about=>'required|min:10'
    ]);

 //   create a car
    $car = new Car();
    $car->user_id=auth()->user()->id;
    $car->name=$request->name;
    $car->type=$request->type;
    $car->color=$request->color;
    $car->about=$request->about;

    $car->save();

    return redirect('home')->with('success','Done The Car is added');
}

here is the messages.blade.php

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

@if(session('success'))
<div class="alert alert-success">
    
</div>@endif



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire