@props(['name', 'id', 'value' => null, 'records' => [], 'type' => 'image']) @php $selectedId = (string) old($name, $value); $items = collect($records) ->filter(fn ($asset) => $type === 'all' || $asset->file_type === $type) ->map(function ($asset) { $path = $asset->file_path; $url = match (true) { str($path)->startsWith(['http://', 'https://', '/']) => $path, str($path)->startsWith(['storage/', 'images/']) => asset($path), ($asset->disk ?: 'public') === 'public' => asset('storage/'.$path), default => \Illuminate\Support\Facades\Storage::disk($asset->disk)->url($path), }; return [ 'id' => (string) $asset->id, 'title' => $asset->title_en ?: basename($path), 'search' => $asset->title_en.' '.$asset->title_as.' '.$path, 'path' => $path, 'type' => $asset->file_type, 'url' => $url, ]; })->values(); @endphp
Choose from the media library below.