K
K
Konstantin B.2016-10-18 11:20:04
Laravel
Konstantin B., 2016-10-18 11:20:04

Make url first parameter optional in Laravel 5?

There is a url structure in which the first parameter can be optional, that is: /msk/catalog/noski /nsk/catalog/noski can
be specified Or maybe not /catalog/noski How can this be implemented? Simply adding ahead does not work, if the city is not specified, it displays that there is no such page, but the url generates the correct one, what could be the problem? {city?}/catalog/{brand?}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
WebDev, 2016-10-18
@kirill-93

Two routes need to be done:
1) /catalog/{brand?}
2) /{city}/catalog/{brand?}
And let them lead to one controller and check for city there

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question