Skip to content

Commit

Permalink
Merge pull request #517 from moebrowne/bugfix/localeless-menu-items-n…
Browse files Browse the repository at this point in the history
…ot-marked-as-active

Use LaravelLocalization When Generating Menu Item URIs
  • Loading branch information
nWidart authored Apr 19, 2018
2 parents b19cafd + a76c0c5 commit 77487a3
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Modules/Menu/Providers/MenuServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Modules\Menu\Providers;

use Illuminate\Support\ServiceProvider;
use Mcamara\LaravelLocalization\Facades\LaravelLocalization;
use Modules\Core\Events\BuildingSidebar;
use Modules\Core\Events\LoadingBackendTranslations;
use Modules\Core\Traits\CanGetSidebarClassForModule;
Expand Down Expand Up @@ -122,7 +123,9 @@ public function addItemToMenu(Menuitem $item, Builder $menu)
]
);
} else {
$target = $item->link_type != 'external' ? $item->locale . '/' . $item->uri : $item->url;
$localisedUri = ltrim(parse_url(LaravelLocalization::localizeURL($item->uri), PHP_URL_PATH), '/');
$target = $item->link_type != 'external' ? $localisedUri : $item->url;

$menu->url(
$target,
$item->title,
Expand Down

0 comments on commit 77487a3

Please sign in to comment.