getOrDefault($key, $default); } } if (! function_exists('languages')) { function languages(): Collection { return app(SettingsService::class)->getLanguages(); } } if (! function_exists('hasPermission')) { function hasPermission(string $permission): bool { return (bool) app(PermissionsService::class)->getOrDefault($permission); } } if (! function_exists('hasHousekeepingPermission')) { function hasHousekeepingPermission(string $permission): bool { return (bool) app(HousekeepingPermissionsService::class)->getOrDefault($permission); } } if (! function_exists('columnExists')) { function columnExists(string $table, string $column): bool { try { return Schema::hasColumn($table, $column); } catch (Throwable) { return false; } } } if (! function_exists('isDarkColor')) { function isDarkColor(string $hexColor): bool { $hex = ltrim($hexColor, '#'); $r = hexdec(substr($hex, 0, 2)); $g = hexdec(substr($hex, 2, 2)); $b = hexdec(substr($hex, 4, 2)); $luminance = (0.299 * $r + 0.587 * $g + 0.114 * $b) / 255; return $luminance < 0.5; } } if (! function_exists('bootstrap_path')) { function bootstrap_path(string $path = ''): string { return base_path('bootstrap' . ($path ? DIRECTORY_SEPARATOR . $path : '')); } } if (! function_exists('logJson')) { function logJson(string $level, string $message, array $context = []): void { try { Log::channel('json')->{$level}($message, $context); } catch (Throwable) { } } }