Skip to content

Commit a8afbba

Browse files
Added support for working without using route grouping
1 parent 9d398ee commit a8afbba

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

helpers/functions.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,9 @@ function localizedRoute(string $route, array $parameters = [], bool $absolute =
1414

1515
$name = Str::start($route, $prefix);
1616

17-
if (! Route::has($name)) {
18-
return route($route, $parameters, $absolute);
19-
}
17+
$route = Route::has($name) ? $name : $route;
2018

21-
return route($name, array_merge([
19+
return route($route, array_merge([
2220
$locale => app()->getLocale(),
2321
], $parameters), $absolute);
2422
}

tests/Unit/Helpers/LocalizedRouteTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
});
2525

2626
test('routes without groups', function () {
27+
$locale = LocaleValue::LocaleMain;
28+
2729
expect(localizedRoute('via.model.default', ['foo' => 'bar']))
28-
->toEndWith('localhost/model/default/bar');
30+
->toEndWith('localhost/model/default/bar?locale=' . $locale);
2931
});

0 commit comments

Comments
 (0)