withoutMagicalCreation()->from([ 'path' => Lazy::create(fn () => $path), 'collection_name' => $collection->name, ]); } public static function collectionFromPaths(Collection $paths, MediaCollection $collection): DataCollection { return static::collect($paths->map(fn ($path) => static::fromPath($path, $collection))); } public function with(): array { $file = new MediaFile(Storage::disk(config('media-library.temp_disk'))->path($this->path->resolve())); return [ 'is_deferred' => true, 'original_url' => $this->storage()->url($this->path->resolve()), 'name' => $file->getBasename(), 'size' => $file->getSize(), 'file_name' => $file->getFilename(), 'mime_type' => $file->getMimeType(), 'icon' => Storage::disk('public')->url('filetypes/' . str()->slug($file->getMimeType()) . '.svg'), ]; } protected function storage(): FilesystemAdapter { return Storage::disk(config('media-library.temp_disk')); } }