Skip to content

Commit

Permalink
add localized currentUrl
Browse files Browse the repository at this point in the history
  • Loading branch information
MoamenEltouny committed Nov 27, 2021
1 parent 1bc5560 commit 0bee8ef
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/Classes/Localization.php
Expand Up @@ -11,7 +11,7 @@
* Laravel URL Localization Manager
* ccTLDs, sub-domains, sub-directories
*
* @version 1.1.0
* @version 1.2.4
* @author Moamen Eltouny (Raggi) <raggi@raggitech.com>
*/
class Localization
Expand Down Expand Up @@ -399,7 +399,7 @@ public function route(string $key, $params = [])
return app('url')->toRoute($route, array_merge($params, ['locale' => $locale]), true);
}

if ($locale == $this->default && $this->hideDefault)
if ($this->type != 'sub-directory' && $locale == $this->default && $this->hideDefault)
return route($key, $params);

return route($key, array_merge(['locale' => $locale . ($this->type == 'sub-domain' ? '.' : null)], $params));
Expand All @@ -416,4 +416,14 @@ public function unLocalizedRoute(string $key, array $params = [])
{
return route($key, $params);
}

/**
* Get Localized route-url
*
* @return string
*/
public function currentUrl()
{
return $this->route(Route::current()->getName(), Route::current()->parameters());
}
}

0 comments on commit 0bee8ef

Please sign in to comment.