I am suffering this problem that says TokenMismatchException in VerifyCsrfToken.php line 53: I am using {!!Form::open()!!} {!!Form::close!!}. When I click add Button in my form with empty field for first time it shows me error as I set validation rule. But when I click Add button again without refreshing the page it shows me TokenMismatchException error. I have checked with dd() and it shows me the token like this:
`array:3 [▼
"_token" => "5dXwRHbz4GNY1tx9OVeWPcOkirVIm0YtpkZufFbr"
"menu_name" => ""
"menu_price" => ""`
here is my form code
{!! Form::open(array('route' =>'upcoming.store', 'method'=>'POST')) !!}
<div class="col-lg-6 col-sm-offset-3 top-spacing">
<input type="text" name="menu_name" placeholder="Menu Name.." class="form-control">
</div>
<div class="col-lg-6 col-sm-offset-3 top-spacing">
<input type="text" name="menu_price" placeholder="Menu Price.." class="form-control">
</div>
<div class="col-sm-2 col-sm-offset-8 top-spacing">
<button class="btn btn-success">
Add +
</button>
</div>
</div>
{!! Form::close() !!}`
Here is my controller store function
public function store(Request $request)
{
dd($request->all());
$this->validate($request, array(
'menu_name'=>'required',
'menu_price'=>'required',
));
$upcoming = new Upcomingfood;
$upcoming->menu_name=$request->menu_name;
$upcoming->menu_price=$request->menu_price;
$upcoming->save();
Session::flash('success','Food Menu Added Successfullly');
return redirect()->back();
}
thanks in advance. It will be really helpful for me if I get my answer as I am new in Laravel.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire