- Added standard Laravel directory structure and configuration. - Included Svelte and Tailwind configuration for the admin interface. - Added core PHPUnit and testing scripts.
41 lines
995 B
PHP
41 lines
995 B
PHP
<?php
|
|
|
|
namespace App\Support;
|
|
|
|
class NavigationManager
|
|
{
|
|
protected array $items = [];
|
|
|
|
/**
|
|
* Register a navigation item.
|
|
*/
|
|
public function register(string $id, string $label, string $url, array $options = [])
|
|
{
|
|
// If it already exists, merge it.
|
|
if (isset($this->items[$id])) {
|
|
$this->items[$id] = array_merge($this->items[$id], [
|
|
'label' => $label,
|
|
'url' => $url,
|
|
], $options);
|
|
} else {
|
|
$this->items[$id] = array_merge([
|
|
'id' => $id,
|
|
'label' => $label,
|
|
'url' => $url,
|
|
'icon' => null,
|
|
'order' => 0,
|
|
'parent' => null,
|
|
], $options);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Get all registered items, sorted by order.
|
|
*/
|
|
public function getItems(): array
|
|
{
|
|
uasort($this->items, fn($a, $b) => $a['order'] <=> $b['order']);
|
|
return $this->items;
|
|
}
|
|
}
|