Spatie\Menu\Menu::setActiveFromUrl PHP Метод

setActiveFromUrl() публичный Метод

, /about, /contact => request to /about will set the about link active. en, /en/about, /en/contact => request to /en won't set /en active if the request root is set to /en.
public setActiveFromUrl ( string $url, string $root = '/' )
$url string The current request url.
$root string If the link's URL is an exact match with the request root, the link won't be set active. This behavior is to avoid having home links active on every request.
    public function setActiveFromUrl(string $url, string $root = '/')
    {
        $this->applyToAll(function (Menu $menu) use($url, $root) {
            $menu->setActiveFromUrl($url, $root);
        });
        $this->applyToAll(function (Activatable $item) use($url, $root) {
            $item->determineActiveForUrl($url, $root);
        });
        return $this;
    }