NavItem
in package
implements
Stringable
Abstraction for a navigation menu item. Used by the NavigationMenu and DocumentationSidebar classes.
You have a few options to construct a navigation menu item:
- You can supply a Route directly and explicit properties to the constructor
- You can use NavItem::fromRoute() to use data from the route
- You can use NavItem::forLink() for an external or un-routed link
Table of Contents
Interfaces
- Stringable
Properties
- $destination : string
- $group : string|null
- $label : string
- $priority : int
Methods
- __construct() : mixed
- Create a new navigation menu item.
- __toString() : string
- Resolve a link to the navigation item.
- forLink() : static
- Create a new navigation menu item leading to an external URI.
- forRoute() : static
- Create a new navigation menu item leading to a Route model.
- fromRoute() : static
- Create a new navigation menu item from a route.
- getDestination() : string
- Get the destination link of the navigation item.
- getGroup() : string|null
- Get the group identifier of the navigation item, if any.
- getLabel() : string
- Get the label of the navigation item.
- getPriority() : int
- Get the priority to determine the order of the navigation item.
- isCurrent() : bool
- Check if the NavItem instance is the current page.
- getRouteGroup() : string|null
- normalizeGroupKey() : string|null
Properties
$destination read-only
public
string
$destination
$group read-only
public
string|null
$group
$label read-only
public
string
$label
$priority read-only
public
int
$priority
Methods
__construct()
Create a new navigation menu item.
public
__construct(Route|string $destination, string $label[, int $priority = 500 ][, string|null $group = null ]) : mixed
Parameters
- $destination : Route|string
- $label : string
- $priority : int = 500
- $group : string|null = null
__toString()
Resolve a link to the navigation item.
public
__toString() : string
Return values
stringforLink()
Create a new navigation menu item leading to an external URI.
public
static forLink(string $href, string $label[, int $priority = 500 ]) : static
Parameters
- $href : string
- $label : string
- $priority : int = 500
Return values
staticforRoute()
Create a new navigation menu item leading to a Route model.
public
static forRoute(Route|string $route[, string|null $label = null ][, int|null $priority = null ][, string|null $group = null ]) : static
Parameters
- $route : Route|string
- $label : string|null = null
-
Leave blank to use the label of the route's corresponding page.
- $priority : int|null = null
-
Leave blank to use the priority of the route's corresponding page.
- $group : string|null = null
-
Leave blank to use the group of the route's corresponding page.
Return values
staticfromRoute()
Create a new navigation menu item from a route.
public
static fromRoute(Route $route[, string|null $label = null ][, int|null $priority = null ][, string|null $group = null ]) : static
Parameters
- $route : Route
- $label : string|null = null
- $priority : int|null = null
- $group : string|null = null
Return values
staticgetDestination()
Get the destination link of the navigation item.
public
getDestination() : string
If the navigation item is an external link, this will return the link as is, if it's for a route, a resolved relative link will be returned.
Return values
stringgetGroup()
Get the group identifier of the navigation item, if any.
public
getGroup() : string|null
For sidebars this is the category key, for navigation menus this is the dropdown key.
Return values
string|nullgetLabel()
Get the label of the navigation item.
public
getLabel() : string
Return values
stringgetPriority()
Get the priority to determine the order of the navigation item.
public
getPriority() : int
Return values
intisCurrent()
Check if the NavItem instance is the current page.
public
isCurrent() : bool
Return values
boolgetRouteGroup()
protected
static getRouteGroup(Route $route) : string|null
Parameters
- $route : Route
Return values
string|nullnormalizeGroupKey()
protected
static normalizeGroupKey(string|null $group) : string|null
Parameters
- $group : string|null