Skip to content

Commit

Permalink
fix getting old values
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianMrn committed Oct 27, 2020
1 parent 9b5624e commit f249471
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/MediaCollections/Models/Collections/MediaCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,19 @@ public function toHtml()

public function jsonSerialize()
{
return old($this->formFieldName ?? $this->collectionName) ?? $this->map(function (Media $media) {
return [
'name' => $media->name,
'file_name' => $media->file_name,
'uuid' => $media->uuid,
'preview_url' => $media->hasGeneratedConversion('preview') ? $media->getUrl('preview') : '',
'order' => $media->order_column,
'custom_properties' => $media->custom_properties,
'extension' => $media->extension,
'size' => $media->size,
];
return ($this->formFieldName ?? $this->collectionName)
? old($this->formFieldName ?? $this->collectionName)
: $this->map(function (Media $media) {
return [
'name' => $media->name,
'file_name' => $media->file_name,
'uuid' => $media->uuid,
'preview_url' => $media->hasGeneratedConversion('preview') ? $media->getUrl('preview') : '',
'order' => $media->order_column,
'custom_properties' => $media->custom_properties,
'extension' => $media->extension,
'size' => $media->size,
];
})->keyBy('uuid');
}
}

0 comments on commit f249471

Please sign in to comment.