@php
$isEdit = filled($record);
$namePrefix = $isEdit ? 'edit_'.$record->id.'_' : 'create_';
$selectedImageId = (string) old('image_id', $record?->image_id);
$mediaAssets = $selectOptions['mediaAssetRecords'] ?? collect();
$mediaImageUrl = static function ($asset) {
if (! $asset?->file_path) {
return null;
}
$path = $asset->file_path;
if (str($path)->startsWith(['http://', 'https://', '/'])) {
return $path;
}
if (str($path)->startsWith('storage/')) {
return asset($path);
}
if (str($path)->startsWith('images/')) {
return asset($path);
}
if (($asset->disk ?: 'public') === 'public') {
return asset('storage/'.$path);
}
return \Illuminate\Support\Facades\Storage::disk($asset->disk)->url($path);
};
@endphp