where('user_id', $userId) ->value('avatar_hash'); } catch (\Throwable $e) { $value = null; } self::$hashCache[$userId] = $value ? (string) $value : null; return self::$hashCache[$userId]; } private static function resolveSize(int $requestedSize): int { $sizes = array_values(array_filter( (array) config('avatars.sizes', [32, 64, 128, 256, 512]), static fn ($size): bool => (int) $size > 0 )); if ($sizes === []) { return max(1, $requestedSize); } sort($sizes); foreach ($sizes as $size) { if ($requestedSize <= (int) $size) { return (int) $size; } } return (int) end($sizes); } }