filament-breezy
filament-breezy copied to clipboard
Another route has already been assigned name: when using Multiple domains on Panels (multiple)
Error when using multiple domains in a panel:
Unable to prepare route [two-factor-authentication] for serialization. Another route has already been assigned name [filament.central-admin.auth.two-factor].
at vendor/laravel/framework/src/Illuminate/Routing/AbstractRouteCollection.php:247
243▕ $route->name($this->generateRouteName());
244▕
245▕ $this->add($route);
246▕ } elseif (! is_null($symfonyRoutes->get($name))) {
➜ 247▕ throw new LogicException("Unable to prepare route [{$route->uri}] for serialization. Another route has already been assigned name [{$name}].");
248▕ }
249▕
250▕ $symfonyRoutes->add($route->getName(), $route->toSymfonyRoute());
251▕
The fix is that the name of the route should contain the domain suffixed in the route name in web.php.
like so: ->name(!empty($domain) ? "{$panelId}.{$domain}." : "{$panelId}.")
Route::domain($domain)
->middleware($panel->getMiddleware())
->name(!empty($domain) ? "{$panelId}.{$domain}." : "{$panelId}.")
->prefix($panel->getPath())