I am new to Laravel and have run into following issue:
I have a form that should redirect on Post request but redirect does not happen.
This is my form:
<form action="{{route('cart-store')}}" method="post">
{{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" class="btn btn-primary shop-button">Add to Card</button>
</form>
This is CartController:
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 was added to your cart!');
}
And this is the route:
Route::post('/cart', 'CartContrloller@store')->name('cart-store');
When I click on submit button, the URL gets filled with product data but I reamain on the same page instead of being regirected to Cart.
I have no clue why this is happenning. Is threre a way to at least find out what is broken? I am on 5.7 version.