/** * Return true if current page is $page. */ public function isPage(string $page, array $parameters = []) : bool { // Check if $page is a route name if ($this->route->has($page)) { if ($parameters) { return $this->url->current() == $this->url->route($page, $parameters); } return $this->route->currentRouteName() == $page; } return str_replace($this->request->root() . '/', '', $this->url->full()) == $page; }
/** * Return a named route if it exists. * * @param string $url * @param array $parameters * * @return string */ protected function parseUrl($url, $parameters) { // If provided $url is a route name... if ($this->route->has($url)) { $url = $this->url->route($url, $parameters); } else { $url = $this->url->to($url, $parameters); } return $url; }
/** * Check if a route with the given name exists. * * @param string $name * @return bool * @static */ public static function has($name) { return \Illuminate\Routing\Router::has($name); }