How to make optional not only a parameter but also a separator in Route::get()?
Hello everybody.
I have a route in routes/web.php:
?} - means that the parameter is optional
Example links:
/account/123/course/123/lesson/123 - correct
/account/123/course/123/lesson - correct
/account/123/course/123 - not correct
How to make optional not only {lesson?} but also the entire part of it /lesson/{lesson?} including /lesson ?
This is not a Filament question.
3 Replies
Is this possible to do or not?
With these two routes, the first route will match the /account/{user}/course/{course} pattern, and the second will match the /account/{user}/course/{course}/lesson/{lesson?} pattern. Both routes can point to the same controller method if your logic for handling them is similar.?
The solution to split one route into different routes works. This is what I did in my project. But I want to combine them into one route. I've read a lot of documentation and it doesn't seem possible to do this. This was possible to do in Lumen, because it used a different engine for processing routes.