From f446363b6aedb4a7d266faac048ba10cc61ac0fb Mon Sep 17 00:00:00 2001 From: Antonio Carlos Ribeiro Date: Sat, 14 Mar 2020 16:48:19 +0100 Subject: [PATCH] Fix route name duplicating prefix and module --- src/Helpers/routes_helpers.php | 2 +- src/RouteServiceProvider.php | 39 +++++++++++++++++----------------- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/src/Helpers/routes_helpers.php b/src/Helpers/routes_helpers.php index 0a2baeaab..0e7141938 100644 --- a/src/Helpers/routes_helpers.php +++ b/src/Helpers/routes_helpers.php @@ -1,7 +1,7 @@ group( [ 'middleware' => $supportSubdomainRouting - ? ['supportSubdomainRouting'] - : [], + ? ['supportSubdomainRouting'] + : [], ], function ($router) { require __DIR__ . '/../routes/auth.php'; @@ -101,8 +101,8 @@ function ($router) { $router->group( [ 'middleware' => $this->app->environment('production') - ? ['twill_auth:twill_users'] - : [], + ? ['twill_auth:twill_users'] + : [], ], function ($router) { require __DIR__ . '/../routes/templates.php'; @@ -126,9 +126,9 @@ function ($router) use ($internalRoutes, $supportSubdomainRouting) { $router->group( [ 'domain' => - config('twill.admin_app_subdomain', 'admin') . - '.{subdomain}.' . - config('app.url'), + config('twill.admin_app_subdomain', 'admin') . + '.{subdomain}.' . + config('app.url'), ], $internalRoutes ); @@ -151,8 +151,8 @@ function ($router) { 'middleware' => $this->app->environment( 'production' ) - ? ['twill_auth:twill_users'] - : [], + ? ['twill_auth:twill_users'] + : [], ], function ($router) { require __DIR__ . '/../routes/templates.php'; @@ -221,13 +221,13 @@ protected function registerMacros() } $routePrefix = empty($routePrefix) - ? '/' - : (Str::startsWith($routePrefix, '/') - ? $routePrefix - : '/' . $routePrefix); - $routePrefix = Str::endsWith($routePrefix, '/') + ? '/' + : (Str::startsWith($routePrefix, '/') ? $routePrefix - : $routePrefix . '/'; + : '/' . $routePrefix); + $routePrefix = Str::endsWith($routePrefix, '/') + ? $routePrefix + : $routePrefix . '/'; Route::name($moduleName . '.show')->get( $routePrefix . '{slug}', @@ -310,11 +310,12 @@ protected function registerMacros() } // Check if name will be a duplicate, and prevent if needed/allowed - if ( - !empty($groupPrefix) && - (blank($lastRouteGroupName) || + if (!empty($groupPrefix) && + ( + blank($lastRouteGroupName) || config('twill.allow_duplicates_on_route_names', true) || - !Str::endsWith($lastRouteGroupName, ".{$groupPrefix}.")) + (!Str::endsWith($lastRouteGroupName, ".{$groupPrefix}.")) + ) ) { $customRoutePrefix = "{$groupPrefix}.{$slug}"; $resourceCustomGroupPrefix = "{$groupPrefix}.";