Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When routes are cached, twill navigation doesn't use the correct module #2583

Open
Tofandel opened this issue May 10, 2024 · 1 comment
Open

Comments

@Tofandel
Copy link
Contributor

Tofandel commented May 10, 2024

Given the following twill route

\Illuminate\Support\Facades\Route::prefix('app')->group(function () {
    TwillRoutes::module('users');
});

And the following navigation

        TwillNavigation::addLink(
            NavigationLink::make()
                ->title('Users')
                ->forModule('users')
                ->setChildren([
                    NavigationLink::make()->title('Professions')->forModule('userProfessions'),
                ])
        )

Until I run php artisan route:cache the link in the menu is correct
After the cache, the link goes to /users without the group prefix

image
image

Setting ->forModule('app.users') (the route being listed as twill.app.users.index results in
image

Which is not a descriptive error message

Setting ->forRoute('twill.app.users.index') gives the desired result but it's weird to have the behavior differ between route cached or not (routes are only cached when staging so it's not caught straight away)

@Tofandel
Copy link
Contributor Author

Tofandel commented May 10, 2024

Very likely due to $this->addToRouteRegistry($slug, $customRoutePrefix); which is a side effect in the route registration

My biggest problem is the fact that the twill users management is registered as the users module which is very easy to conflict with user being a very common model name

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant