Matt
Matt

Reputation: 37

my GET route not working in laravel

I am new to laravel and working on a form.

This is the form

<form action="/product" method="GET">
<div class="input-group">
  <input type="text" class="form-control" placeholder="Enter product name" />
  <div class="input-group-btn">
    <input type="submit" class="btn btn-danger" value="Search" />
  </div>
</div>

And this is the Route I have written

Route::get('/product/{product}', 'FlashCartController@find_product');

When I submit my form it says

NotFoundHttpException in RouteCollection.php line 161:

How do I submit this form?

Upvotes: 1

Views: 51

Answers (1)

Margus Pala
Margus Pala

Reputation: 8673

In this case you need product ID in the form action. For example

<form action="/product/{{$productId}}" method="GET">

If you just want to create new product then lose the {product} and change the GET to POST as forms are submitted with mostly with POST.

<form action="/product" method="POST">

Route::post('/product', 'FlashCartController@find_product');

Upvotes: 1

Related Questions