lundi 11 mai 2020

Laravel Route parameter and Query parameter collision

My route for hotels defined in web.php like this:

Route::get('/hotel/{slug}', 'HotelController@show');

and an example slug would be: meis-exclusive-hotel

Also I have query parameters for this route such as checkIn, checkOut and room setup. For the rooms query parameter, I build it like: &rooms=2,1-3-5 which means 2 rooms (separated with comma) and on the 2nd room I have 2 children aged 3 and 5.

The problem is that Laravel treats the rooms query parameter as Route parameter and when I call:

/hotel/meis-exclusive-hotel?checkIn=14.05.2020&checkOut=16.05.2020&rooms=2,1-7-1 the route like this Laravel throws an exception:

Missing required parameters for [Route: ] [URI: hotel/{slug}].

Any solution to this problem?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire