REMOVE THE TRAILING / IN YOUR ROUTE!!!!!
Route::get('/cart', 'CartController@index')->name('cart.index');
Route::post('/cart', 'CartController@index')->name('cart.store');
PLEASE SOMEONE HELP ME, THE CODE ERROR IS : Route [cart.index] not defined.
THIS IS MY ROUTE ;
Route::get('/cart/', 'CartController@index')->name('cart.index');
Route::post('/cart/', 'CartController@store')->name('cart.store');
AND THIS IS MY CART CONTROLLER :
public function store(Request $request)
{
Cart::add($request->id, $request->name, 1, $request->price)
->associate('App\Product');
return redirect()->route('cart.index')->with('success_message', 'Item added to your cart!');
}
MY ADD TO CARD FORM :
<form class="cart clearfix" method="post" action="{{ route('cart.store') }}">
{{ csrf_field() }}
<input type="hidden" name="id" value="{{$product->id}}">
<input type="hidden" name="name" value="{{$product->name}}">
<input type="hidden" name="price" value="{{$product->price}}">
<button type="submit" name="addtocart" value="5" class="btn amado-btn">Add to cart</button>
</form>
WARNING: IF YOUR ANSWER IS SO ABUSIVE I WILL GIVE IT BACK TO YOU IN FULL MEASURE. THANKS.
Please or to participate in this conversation.