27 lines
668 B
PHP
27 lines
668 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Lib\PublicS3Disk;
|
|
use Uwil\Storage\Lib\ValueObjects\StorageFilePath;
|
|
|
|
if (! function_exists('publicS3Asset')) {
|
|
function publicS3Asset(StorageFilePath | string | null $path): ?string
|
|
{
|
|
if ($path === null || $path === '') {
|
|
return null;
|
|
}
|
|
|
|
$pathValue = $path instanceof StorageFilePath
|
|
? $path->value
|
|
: $path;
|
|
|
|
if (str_starts_with($pathValue, 'http://') || str_starts_with($pathValue, 'https://')) {
|
|
return $pathValue;
|
|
}
|
|
|
|
$s3Disk = app()->make(PublicS3Disk::class);
|
|
|
|
return $s3Disk->publicUrlOf($pathValue);
|
|
}
|
|
}
|