<?php

namespace App\Helpers;

use Illuminate\Support\Facades\Storage;

class UrlHelper
{
    /**
     * Convert a storage path to a full URL
     * 
     * @param string|null $path
     * @return string|null
     */
    public static function toFullUrl(?string $path): ?string
    {
        if (!$path) {
            return null;
        }

        // If already a full URL, return as is
        if (str_starts_with($path, 'http://') || str_starts_with($path, 'https://')) {
            return $path;
        }

        // Use Storage::url() to generate full URL based on filesystem config
        return Storage::disk('public')->url($path);
    }
}

