fix financial and certificates

This commit is contained in:
root
2026-06-05 01:51:08 -04:00
parent d28d11e2e5
commit ad968eaff7
94 changed files with 9654 additions and 214 deletions
+30 -1
View File
@@ -21,7 +21,9 @@ class NavbarService
$rows = NavItem::query()
->where('is_enabled', 1)
->orderBy('sort_order', 'asc')
->orderBy('menu_parent_id', 'asc')
->orderBy('label', 'asc')
->orderBy('id', 'asc')
->get()
->toArray();
@@ -44,6 +46,8 @@ class NavbarService
}
unset($node);
$this->sortTreeAlpha($tree);
return $tree;
});
}
@@ -52,4 +56,29 @@ class NavbarService
{
Cache::flush();
}
private function labelKey(string $s): string
{
$s = trim(preg_replace('/\s+/', ' ', $s));
$s = preg_replace('/^[^[:alnum:]]+/u', '', $s);
$s = preg_replace('/^(?i)(the|an|a)\s+/', '', $s);
return mb_strtolower($s, 'UTF-8');
}
private function sortTreeAlpha(array &$nodes): void
{
usort($nodes, function ($a, $b) {
$result = strnatcasecmp($this->labelKey($a['label'] ?? ''), $this->labelKey($b['label'] ?? ''));
return $result !== 0 ? $result : ((int) ($a['id'] ?? 0) <=> (int) ($b['id'] ?? 0));
});
foreach ($nodes as &$node) {
if (!empty($node['children'])) {
$this->sortTreeAlpha($node['children']);
}
}
unset($node);
}
}