Reputation: 23
This is my form and I'm trying to send the id and the title of a product to the controller but I have no clue why I got null as a value.
show.blade.php:
<form action="{{ route('cart.store') }}" method="POST">
@csrf
<input type="hidden" name="product_id" value="{{ $product->id }}">
<input type="hidden" name="product_name" value="{{ $product->title }}">
<button type="submit" class="ps-btn mb-10">J'encheris <i class="ps-icon-next"></i></button>
</form>
web.php:
Route::post('/MesEnchers/ajouter', 'CartController@store')->name('cart.store');
CartController.php :
public function store(Request $request)
{
dd($request->id, $request->title);
}
Upvotes: 2
Views: 981
Reputation: 17206
Your variables are product_id
& product_name
not id
& title
try
public function store(Request $request)
{
dd($request->product_id, $request->product_name);
}
Upvotes: 3