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

[4.x] Prefix internal Twill users module routes to prevent conflicts with another User model #2583

Open
Tofandel opened this issue May 10, 2024 · 1 comment
Labels
type: enhancement New feature or request

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, maybe we should have the default user route under a prefix to avoid those issues (but would have to be v4 likely or maybe in v3 it could be enabled with an option)

@ifox ifox changed the title When routes are cached, twill navigation doesn't use the correct module Prefix internal Twill users module routes to prevent conflicts with another User model May 30, 2024
@ifox ifox added the type: enhancement New feature or request label May 30, 2024
@ifox ifox changed the title Prefix internal Twill users module routes to prevent conflicts with another User model [4.x] Prefix internal Twill users module routes to prevent conflicts with another User model May 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement New feature or request
Projects
Status: Beyond
Development

No branches or pull requests

2 participants