Files
opensem/app/Repositories/Core/Menu/Item.php
2024-01-05 01:30:46 +01:00

58 lines
1.3 KiB
PHP

<?php
namespace App\Repositories\Core\Menu;
use Lavary\Menu\Item as LavaryMenuItem;
class Item extends LavaryMenuItem
{
public function icon($icon)
{
$this->prepend(sprintf('<i class="%s"></i>', $icon));
return $this;
}
public function order($order)
{
$this->data('order', $order);
return $this;
}
public function activeIfRoute($routes = null)
{
if ($routes) {
if (is_string($routes)) {
$routes = [$routes];
}
foreach ($routes as $pattern) {
$arr = [$pattern];
if (! if_route_pattern($arr)) {
continue;
}
$this->activate();
if (strstr($this->title, 'circle-o')) {
$this->title = str_replace('fa-circle-o', 'fa-dot-circle-o', $this->title);
}
return $this;
}
return $this;
}
$activeClass = $this->builder->conf('active_class');
$this->attributes['class'] = Builder::formatGroupClass(['class' => $activeClass], $this->attributes);
$this->isActive = true;
if (strstr($this->title, 'circle-o')) {
$this->title = str_replace('fa-circle-o', 'fa-dot-circle-o', $this->title);
}
return $this;
}
}