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
|
||||
{
|
||||
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
|
||||
|
|
|
@ -66,7 +66,7 @@ class MediaController
|
|||
|
||||
$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)
|
||||
|
@ -98,7 +98,7 @@ class MediaController
|
|||
});
|
||||
|
||||
$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
|
||||
|
@ -132,7 +132,7 @@ class MediaController
|
|||
|
||||
return $isSingle
|
||||
? MediaData::from($model->getFirstMedia($collectionName))
|
||||
: MediaData::collection($model->getMedia($collectionName));
|
||||
: MediaData::collect($model->getMedia($collectionName));
|
||||
}
|
||||
|
||||
public function destroy(Media $media, Request $request): JsonResponse
|
||||
|
|
|
@ -16,7 +16,7 @@ class OrderController
|
|||
$mediaCount = collect($request->order)->map(function ($media) {
|
||||
$media = Media::findOrFail($media);
|
||||
|
||||
return $media->model_id.'_'.$media->model_type;
|
||||
return $media->model_id . '_' . $media->model_type;
|
||||
})->unique()->count();
|
||||
|
||||
if (1 !== $mediaCount) {
|
||||
|
@ -31,6 +31,6 @@ class OrderController
|
|||
|
||||
$model->getMediaCollection($collectionName)->runCallback('after', $model->fresh());
|
||||
|
||||
return MediaData::collection($model->getMedia($collectionName));
|
||||
return MediaData::collect($model->getMedia($collectionName));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue