Links¶
Links are single objects under a menu that are meant to be used to create an html link. You have the option to create a link manually or via the quick link method.
$menu->link('slug', function (Link $link) {
$link->name = 'Take me to google';
$link->url = 'http://google.com';
$link->options = ['class' => 'btn'];
});
Name¶
The name property is used to create the human readable link text.
URL¶
The url is the address the link will point to.
Options¶
Options can be used for extra properties for the link like: class, alt-text, style, exc.
Set Options¶
Set the options array
Note
Options are saved as an array. Adding options just merges the new options into the array.
$link->options = [
'class' => 'btn-warning'
];
Active Flag¶
The active property is used to show which link is currently active. (Default: false)
Set Active Flag¶
Set the active flag. The default parameter for setActive
is true
// Set link to active
$link->setActive();
$link->setActive(true);
// Set link to inactive
$link->setActive(false);
Insert After/Before¶
You can tell a link to be inserted before or after another link or dropdown.
Parameters: slug: The slug of the link or drop down to insert before or after.
$link->insertAfter('slug');
$link->insertBefore('slug');