Closed guilheb closed 8 months ago
Thanks for the PR 👍🏻 Ziggy can't call usePage()
internally because it's not just used in Inertia apps. The best way to make sure all routes are always available is to use the @routes
Blade directive. If you don't want to do that the simplest alternative is overriding the route function in your own app, like you did.
As discussed in https://github.com/tighten/ziggy/discussions/696, it would be really nice for the
route()
function to always have up-to-date routes.The simplest use-case is having a small set of routes for the whole world to see (login, registration, etc) and then have access to all routes once a user is logged in. This is easily achievable in HandleInertiaRequest, but the JavaScript object is never updated. This PR ensure the
route()
function uses the fresh list of routes.