Skip to content
This repository was archived by the owner on Jan 3, 2023. It is now read-only.

Commit 98fef5e

Browse files
committed
make route param session dynamic
1 parent fa084a0 commit 98fef5e

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

src/Traits/NavigationTrait.php

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ public function getUrl($code)
2626
$routesListFile = include $this->listFileDir;
2727

2828
if (is_null($name) || !array_get($routesListFile, $name)) {
29-
return LaravelLocalization::getLocalizedURL(
30-
$code, null, [], true
31-
);
29+
return LaravelLocalization::getLocalizedURL($code, null, [], true);
3230
}
3331

3432
$url = $this->routeLink($name, $code);
@@ -37,15 +35,11 @@ public function getUrl($code)
3735
if (session()->has($name)) {
3836
$params = session()->get($name);
3937

40-
return LaravelLocalization::getLocalizedURL(
41-
$code, url($this->getParams($url, $params)), [], true
42-
);
38+
return LaravelLocalization::getLocalizedURL($code, url($this->getParams($url, $params)), [], true);
4339
}
4440

4541
// no params
46-
return LaravelLocalization::getLocalizedURL(
47-
$code, url($this->rmvUnUsedParams($url)), [], true
48-
);
42+
return LaravelLocalization::getLocalizedURL($code, url($this->rmvUnUsedParams($url)), [], true);
4943
}
5044

5145
/**
@@ -65,9 +59,7 @@ public function getRoute($crntRouteName, array $params = null)
6559
if ($params) {
6660
foreach ($params as $key => $value) {
6761
if ($crntRouteName == $key) {
68-
if (!session()->has($crntRouteName)) {
69-
session([$crntRouteName => $value]);
70-
}
62+
session([$crntRouteName => $value]);
7163

7264
// fix link not being 'is-active' when "hideDefaultLocaleInURL => true"
7365
if (LaravelLocalization::hideDefaultLocaleInURL() && $code == LaravelLocalization::getDefaultLocale()) {
@@ -77,13 +69,15 @@ public function getRoute($crntRouteName, array $params = null)
7769
}
7870

7971
$this->urlRoute = $finalUrl;
72+
8073
return $finalUrl;
8174
}
8275
}
8376
}
8477

85-
$finalUrl = route($crntRouteName);
78+
$finalUrl = route($crntRouteName);
8679
$this->urlRoute = $finalUrl;
80+
8781
return $finalUrl;
8882
}
8983

0 commit comments

Comments
 (0)