Skip to content

Commit

Permalink
Update helpers.php
Browse files Browse the repository at this point in the history
  • Loading branch information
sertxudev committed Feb 26, 2024
1 parent 3cab8c1 commit b17b3fb
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/Helpers/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,20 @@ function switch_to_locale($locale) {
}

if (!function_exists('is_route')) {
function is_route(string $name): bool {
function is_route($patterns): bool {
$patterns = Arr::wrap($patterns);

/** Check route without locales */
if (request()->routeIs($name)) {
if (request()->routeIs($patterns)) {
return true;
}

/** Check route with locales */
foreach (config('translatable.locales') as $locale) {
if (request()->routeIs("$locale.$name")) {
return true;
foreach ($patterns as $pattern) {
if (request()->routeIs("$locale.$pattern")) {
return true;
}
}
}

Expand Down

0 comments on commit b17b3fb

Please sign in to comment.