Reputation: 1390
In Laravel, I want to have dynamic routes for simple pages functionality.
So say I have couple routes, like /blog
will call BlogController and so on. And I have routes like this /page/{slug}
that call PageController.
How can I do it so if route is not found (for example /my-test-page
), the system would call the controller as if the route was /page/my-test-page
(so that 404 is only throw if PageController cannot find the page in the database).
I saw I can catch the 404 exceptions, but I don't know how I can simulate the route call to PageController from there?
Thanks a lot!
Upvotes: 1
Views: 208
Reputation: 32
redirect(action(PageController@methodName))
Does this solves your problem? Of course you will need to import the redirect() method.
Upvotes: 1