public function addItem($perams = array())
{
$defaults = array('text' => '', 'URL' => '#', 'reference' => 0, 'parent' => false, 'weight' => 1, 'class' => '', 'children' => array(), 'icon' => '', 'attributes' => array(), 'protected' => false);
if (isset($perams['URL']) && preg_match("#^route:(.*)\$#is", $perams['URL'], $match)) {
if (isset($perams['protected']) && $perams['protected']) {
$perams['protected'] = $match[1];
}
if ($this->entrust && \Auth::check()) {
$roles = \Auth::user()->roles()->get();
$allowed = true;
foreach ($roles as $role) {
foreach ($role->perms as $perm) {
if (in_array($match[1], $perm->protected_routes)) {
$perams['URL'] = \URL::route($match[1]);
$this->items[] = array_merge($defaults, $perams);
}
}
}
return $this;
} else {
$perams['URL'] = \URL::route($match[1]);
}
}
$this->items[] = array_merge($defaults, $perams);
return $this;
}