Files
opensem/app/Repositories/Core/Menu/Item.php
Ludovic CANDELLIER 0879b0abf0 add shipping rules
2023-07-16 14:45:42 +02:00

76 lines
1.7 KiB
PHP

<?php
namespace App\Repositories\Core\Menu;
use Lavary\Menu\Item as LavaryMenuItem;
class Item extends LavaryMenuItem
{
/**
* Set the item icon using font-awesome.
*
*
* @return self
*/
public function icon($icon)
{
$this->prepend(sprintf('<i class="%s"></i>', $icon));
return $this;
}
/**
* Set the item order.
*
*
* @return self
*/
public function order($order)
{
$this->data('order', $order);
return $this;
}
/**
* Make the item active.
*
* @param string|array $routes
* @return self
*/
public function activeIfRoute($routes = null)
{
if (! empty($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);
}
// dump($this);
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;
}
}