© 2026 Hedgehog Software, LLC
SpatieMediaLibraryFileUpload.php
$this->loadStateFromRelationshipsUsing(static function (SpatieMediaLibraryFileUpload $component, HasMedia $record): void { /** @var Model&HasMedia $record */ // Changed here $record->load('media') $media = $record->getMedia($component->getCollection() ?? 'default') ->when( $component->hasMediaFilter(), fn (Collection $media) => $component->filterMedia($media) ) ->when( !$component->isMultiple(), fn (Collection $media): Collection => $media->take(1), ) ->mapWithKeys(function (Media $media): array { $uuid = $media->getAttributeValue('uuid'); return [$uuid => $uuid]; }) ->toArray(); $component->state($media); });
public function mount() { $this->model->load('media'); $this->form->fill($this->data); }