Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use request()->segment(1) instead of route()->getPrefix() #16

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Middleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Middleware
public function handle(Request $request, Closure $next)
{
$route = $request->route();
$prefix = $route->getPrefix();
$prefix = $request->segment(1);

// Hide default locale /en to /
if (config('loki.hideDefaultLocale') == true and $prefix == config('loki.defaultLocale')) {
Expand Down
4 changes: 2 additions & 2 deletions src/UrlGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public function getLocalizedRoute($locale, $name = null, $parameters = [], $abso
}

$name = $route->getName();
$prefix = $route->getPrefix();
$prefix = request()->segment(1);
// This is a fix for Laravel 6.
// TODO: Maybe this is not needed anymore...
$parameters = array_key_exists('data', $route->parameters) ? $route->parameters['data'] : $route->parameters;
Expand All @@ -131,7 +131,7 @@ public function getLocalizedUrl($locale, $path = null, $extra = [], $secure = nu
{
if (is_null($path)) {
$path = request()->path();
$prefix = request()->route()->getPrefix();
$prefix = request()->segment(1);

if (!is_null($prefix)) {
$path = Str::replaceFirst($prefix, '', $path);
Expand Down