Files
hermes d4928789c4
Deploy HickLab3D Dashboard / Deploy to production (push) Failing after 23s
Add HL3D branding, Etsy Live/Draft paging and Projects lifecycle
Replace the old touchmark/PNG identity with the supplied lockup and
monogram, segmented role-aware navigation, Live/Draft listing filters
with generation-based cache invalidation, and admin Projects covering
immutable file revisions, listing live pointers, and exact-decimal
filament/packaging/shipping costing. Additive schema only; no Etsy
publication. Isolated clone tests: 301 tests, 1162 assertions.
2026-11-08 12:50:56 +00:00

69 lines
2.6 KiB
PHP

<?php
namespace App\Support;
use App\Models\User;
class Navigation
{
/**
* @return list<array{key: string, label: string, items: list<array{route: string, label: string, activePatterns: list<string>}>}>
*/
public static function groups(User $user): array
{
$isAdmin = $user->role === 'admin';
$groups = [
[
'key' => 'workspace',
'label' => 'Workspace',
'items' => [
['route' => 'dashboard', 'label' => 'Overview', 'activePatterns' => ['dashboard'], 'admin' => false],
['route' => 'projects.index', 'label' => 'Projects', 'activePatterns' => ['projects.*'], 'admin' => true],
],
],
[
'key' => 'workshop',
'label' => 'Workshop',
'items' => [
['route' => 'printers.index', 'label' => 'Print farm', 'activePatterns' => ['printers.*'], 'admin' => false],
['route' => 'dryer', 'label' => 'Dryer', 'activePatterns' => ['dryer', 'dryer.*'], 'admin' => false],
],
],
[
'key' => 'commerce',
'label' => 'Commerce',
'items' => [
['route' => 'etsy.index', 'label' => 'Etsy', 'activePatterns' => ['etsy.*'], 'admin' => true],
['route' => 'shipping', 'label' => 'Shipping', 'activePatterns' => ['shipping', 'shipping.*'], 'admin' => true],
],
],
[
'key' => 'administration',
'label' => 'Administration',
'items' => [
['route' => 'settings.index', 'label' => 'Settings', 'activePatterns' => ['settings.*'], 'admin' => true],
['route' => 'users.index', 'label' => 'Users', 'activePatterns' => ['users.*'], 'admin' => true],
],
],
];
return array_values(array_map(
fn (array $group): array => [
'key' => $group['key'],
'label' => $group['label'],
'items' => array_values(array_filter(
array_map(fn (array $item): array => [
'route' => $item['route'],
'label' => $item['label'],
'activePatterns' => $item['activePatterns'],
], $group['items']),
fn (array $item, int $index) => ! $group['items'][$index]['admin'] || $isAdmin,
ARRAY_FILTER_USE_BOTH,
)),
],
$groups,
));
}
}