Fix media data
This commit is contained in:
parent
77cfe9bbc7
commit
e9975e9c5a
|
@ -31,7 +31,7 @@ class DeferredMediaData extends Data
|
||||||
|
|
||||||
public static function collectionFromPaths(Collection $paths, MediaCollection $collection): DataCollection
|
public static function collectionFromPaths(Collection $paths, MediaCollection $collection): DataCollection
|
||||||
{
|
{
|
||||||
return static::collection($paths->map(fn ($path) => static::fromPath($path, $collection)));
|
return static::collect($paths->map(fn ($path) => static::fromPath($path, $collection)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function with(): array
|
public function with(): array
|
||||||
|
|
|
@ -66,7 +66,7 @@ class MediaController
|
||||||
|
|
||||||
$collection->runCallback('after', $model->fresh());
|
$collection->runCallback('after', $model->fresh());
|
||||||
|
|
||||||
return $isSingle ? MediaData::from($medias->first()) : MediaData::collection($medias);
|
return $isSingle ? MediaData::from($medias->first()) : MediaData::collect($medias);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function storeDeferred(Request $request)
|
protected function storeDeferred(Request $request)
|
||||||
|
@ -98,7 +98,7 @@ class MediaController
|
||||||
});
|
});
|
||||||
|
|
||||||
$this->authorize('storeMedia', [$modelName, null, $collection->name]);
|
$this->authorize('storeMedia', [$modelName, null, $collection->name]);
|
||||||
return $isSingle ? DeferredMediaData::fromPath($tempPaths->first(), $collection) : DeferredMediaData::collectionFromPaths($tempPaths, $collection);
|
return $isSingle ? DeferredMediaData::fromPath($tempPaths->first(), $collection) : DeferredMediaData::collect($tempPaths, $collection);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update(Request $request, Media $media): MediaData
|
public function update(Request $request, Media $media): MediaData
|
||||||
|
@ -132,7 +132,7 @@ class MediaController
|
||||||
|
|
||||||
return $isSingle
|
return $isSingle
|
||||||
? MediaData::from($model->getFirstMedia($collectionName))
|
? MediaData::from($model->getFirstMedia($collectionName))
|
||||||
: MediaData::collection($model->getMedia($collectionName));
|
: MediaData::collect($model->getMedia($collectionName));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function destroy(Media $media, Request $request): JsonResponse
|
public function destroy(Media $media, Request $request): JsonResponse
|
||||||
|
|
|
@ -31,6 +31,6 @@ class OrderController
|
||||||
|
|
||||||
$model->getMediaCollection($collectionName)->runCallback('after', $model->fresh());
|
$model->getMediaCollection($collectionName)->runCallback('after', $model->fresh());
|
||||||
|
|
||||||
return MediaData::collection($model->getMedia($collectionName));
|
return MediaData::collect($model->getMedia($collectionName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue