@props([ 'active' => null, // nazwa trasy aktywnej pozycji (np. 'wells.index') 'section' => null, // klucz sekcji (gdy strona nie jest pozycją menu, np. landing sekcji) 'title' => 'SoftSPM 2', ]) @php $sections = config('navigation'); // Ustal aktywną sekcję: jawny prop > sekcja zawierająca aktywną pozycję > pierwsza. $activeSectionKey = $section; if (! $activeSectionKey && $active) { foreach ($sections as $s) { foreach ($s['items'] as $it) { if (($it['route'] ?? null) === $active) { $activeSectionKey = $s['key']; break 2; } } } } $activeSectionKey = $activeSectionKey ?? ($sections[0]['key'] ?? null); $activeSection = collect($sections)->firstWhere('key', $activeSectionKey); // Motyw z cookie (serwer ustawia klasę przy renderze - brak migotania). // Czytamy SUROWE $_COOKIE - cookie 'theme' ustawia JS bez szyfrowania, więc // request()->cookie() (przez EncryptCookies) by go nie odczytał. $theme = ($_COOKIE['theme'] ?? null) === 'dark' ? 'dark' : 'light'; // Inicjały użytkownika do awatara w menu. $uname = auth()->user()?->USR_USERNAME ?? '?'; $unameParts = preg_split('/[^\p{L}\p{N}]+/u', $uname, -1, PREG_SPLIT_NO_EMPTY) ?: [$uname]; $initials = mb_strtoupper(count($unameParts) >= 2 ? mb_substr($unameParts[0], 0, 1).mb_substr($unameParts[1], 0, 1) : mb_substr($uname, 0, 2)); $languages = ['pl' => 'PL', 'en' => 'EN', 'de' => 'DE']; @endphp