Skip to content
niknetniko edited this page Mar 5, 2016 · 5 revisions

Assigning Meta Data

Caffeinated Menus provides the means to add any number of additional meta data to your menu items. It can be anything from item order placement information to permissions required to view or access the item's link, to anything else you can think of or need. This is achievable by utilizing the data() method against your menu item.

...

$menu->add('Dashboard', 'admin')
    ->data('order' => 0);

...

You have a couple ways to assigning meta data to your menu items; key-value pairing as shown in the example above, or through an associative array:

...

$menu->add('Dashboard', 'admin')
    ->data([
        'order' => 0,
        'permission' => 'view_admin_dashboard',
        'lorem' => 'ipsum'
    ]);

...

Retrieving Meta Data

Once meta data has been assigned, you may also retrieve the information back:

...

echo $menu->dashboard->order;       // Will echo 0
echo $menu->dashboard->permission;  // Will echo "view_admin_dashboard"
echo $menu->dashboard->lorem;       // Will echo "ipsum"

...