> */ public static function items(?Authenticatable $user = null): array { $user ??= auth()->user(); if (! $user) { return []; } $items = []; foreach ([ ['label' => 'Home', 'path' => '', 'host' => 'home'], ['label' => 'Profile', 'path' => 'profile'], ['label' => 'Account Settings', 'path' => 'account-settings'], ['label' => 'Dashboard', 'path' => 'dashboard'], ['label' => 'Billing', 'path' => 'billing'], ] as $link) { $items[] = [ 'type' => 'link', 'label' => $link['label'], 'href' => self::platformUrl($link['host'] ?? 'account', $link['path']), ]; } if (self::userIsAdmin($user)) { $items[] = [ 'type' => 'link', 'label' => 'Admin', 'href' => self::platformUrl('account', 'admin'), ]; } if (Route::has('logout')) { $items[] = [ 'type' => 'logout', 'label' => 'Logout', 'action' => route('logout'), ]; } return $items; } private static function platformUrl(string $host, string $path = ''): string { if ($host === 'home') { if (function_exists('ladill_home_url')) { return ladill_home_url($path); } $domain = config('app.home_domain'); if (! $domain) { $platform = (string) config('app.platform_domain', parse_url((string) config('app.url', ''), PHP_URL_HOST) ?: ''); $domain = $platform !== '' ? 'home.'.$platform : (string) config('app.account_domain'); } return self::absoluteUrl((string) $domain, $path); } if (function_exists('ladill_account_url')) { return ladill_account_url($path); } return self::absoluteUrl((string) config('app.account_domain'), $path); } private static function absoluteUrl(string $domain, string $path = ''): string { $base = 'https://'.trim($domain, '/'); if ($path === '') { return $base; } return $base.'/'.ltrim($path, '/'); } private static function userIsAdmin(Authenticatable $user): bool { if (method_exists($user, 'isAdmin')) { return $user->isAdmin(); } return (bool) ($user->is_admin ?? false); } }