mercredi 12 décembre 2018

how to solve Laravel routes conflict

this is a simple code to search in laravel. the route "product" has no problem at all, but, when I use the route "searchproduct", the url in the browser looks like this:

http://example.com/application/public/product/search?q=red+dead

so the application thinks that i'm trying to get the route "product" and send the parameter urlkey as "search?q=red+dead", which ofcourse throw an error.

View

<form method="GET" action="" >
    <input id="q" name="q" class="q" type="text" />
    <button type="submit" id="submitButton" class="btn btn-primary">Go</button>

</form>

Routes

Route::get('product/{urlkey}','ProductController@index')->name('product');
Route::get('product/search/{q?}','ProductController@search')->name('searchproduct');

how to solve this issue please?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire