lundi 21 septembre 2015

Control multiple parameter with dashes in url

I am using laravel 5.0 framework and I have a route like this:

http://ift.tt/1Qv0re8

Where size is an optional parameter

Route::any('embed-{title}-{size?}',['uses'=>'Posts@getData','as'=>'embed'])->where('title', '.*(?=-)');

Because my title contains dashes so it was ignoring my optional size parameter so I have researched and found this ->where('title', '.*(?=-)'); which is working good. Now the problem comes that I have to allways add size parameter. If no size parameter the route is not working so it gives me a 404.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire