diff --git a/src/Fields/Media.php b/src/Fields/Media.php index da35ffc2..9cb277a8 100644 --- a/src/Fields/Media.php +++ b/src/Fields/Media.php @@ -241,13 +241,17 @@ public function mapOption(RootRequest $request, Model $model, Model $related): a { $relation = $this->getRelation($model); + $pivot = $related->relationLoaded($relation->getPivotAccessor()) + ? $related->getRelation($relation->getPivotAccessor()) + : $relation->newPivot(); + return array_merge( parent::mapOption($request, $model, $related), $related->append(['dimensions', 'formatted_size'])->toArray(), [ 'fields' => $this->resolveFields($request) ->available($request, $model, $related) - ->mapToForm($request, $relation->newPivot()) + ->mapToForm($request, $pivot) ->toArray(), 'formatted_created_at' => $related->created_at->format('Y-m-d H:i'), ], diff --git a/src/Root.php b/src/Root.php index f79886ab..7f9f3ffd 100644 --- a/src/Root.php +++ b/src/Root.php @@ -15,7 +15,7 @@ abstract class Root * * @var string */ - public const VERSION = '0.9.0'; + public const VERSION = '0.9.1'; /** * The registered callbacks.