1. Go to this page and download the library: Download acid-solutions/menufactory library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
$menu->renderHtml();
// OR
MenuFactory::render('MenuName');
$menu->add('Menu without Child but with pattern')->pattern('<strong>__LABEL__</strong>');
# OR
$pattern = '<strong>__LABEL__</strong>';
$menu->add('Menu without Child but with pattern1')->pattern($pattern);
$menu->add('Menu without Child but with pattern2')->pattern($pattern);
$menu->add('Menu without Child but with pattern3')->pattern($pattern);
$menu->add('Menu with chained child')->add('First level')->add('Second level')->add('third level')->add('Fourth level');
$menu->add('Menu with multiple child defined by closure', function ($menu) {
$menu->add('first child');
$menu->add('second child');
$menu->add('third child');
});
$menu->add('Menu with multiple child with multiple child defined by closure', function ($menu) {
$menu->add('first child', function ($menu) {
$menu->add('first child');
$menu->add('second child');
$menu->add('third child');
});
$menu->add('second child', function ($menu) {
$menu->add('first child');
$menu->add('second child');
$menu->add('third child');
});
$menu->add('third child', function ($menu) {
$menu->add('first child');
$menu->add('second child');
$menu->add('third child');
});
});
// Using Sentry::check() for this example (it will check if user is auth)
$userAuth = Sentry::check();
$menu->add('Menu with allow function')->allow(function () use ($userAuth) {
// You can do everything you want here
return $userAuth;
});
$menu->add('Menu with allow function (gonna be hide)')->allow(function () use ($userAuth) {
// You can do everything you want here
return !$userAuth;
});
// Wait, why closure if i've the value?
$menu->add('Menu with allow function (gonna be hide)')->allow($userAuth);
$menu->add('Menu with Option')->option('class', 'btn');