Skip to content

Commit

Permalink
fix last commit
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianMrn committed Oct 27, 2020
1 parent 00c5e14 commit 9ac9125
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions src/MediaCollections/Models/Collections/MediaCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,21 @@ public function toHtml()

public function jsonSerialize()
{
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');
if (!($this->formFieldName ?? $this->collectionName)) {
return [];
}

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,
];
})->keyBy('uuid');
}
}

0 comments on commit 9ac9125

Please sign in to comment.