|
@@ -67,7 +67,8 @@ class ContainerController extends Controller
|
|
|
$files = File::query()->where('object_id', $container->id)
|
|
|
->where('object_type', ActionObjectType::CONTAINER)
|
|
|
->where('source', 1)
|
|
|
- ->pluck("id");
|
|
|
+ ->pluck("id")
|
|
|
+ ->sort();
|
|
|
|
|
|
$contentFormData = [
|
|
|
'description' => $imageUrlService->interceptImageUrl($request->description),
|
|
@@ -100,7 +101,6 @@ class ContainerController extends Controller
|
|
|
public function update(
|
|
|
CreateOrUpdateRequest $request,
|
|
|
ImageUrlService $imageUrlService,
|
|
|
- FileAssociationService $service,
|
|
|
CustomFieldRepository $customFieldRepo,
|
|
|
string $id
|
|
|
)
|
|
@@ -120,6 +120,35 @@ class ContainerController extends Controller
|
|
|
|
|
|
$container->fill($formData);
|
|
|
$changes = ModelChangeDetector::detector(ActionObjectType::CONTAINER, $container);
|
|
|
+
|
|
|
+ $files = File::query()->where('object_id', $container->id)
|
|
|
+ ->where('object_type', ActionObjectType::CONTAINER)
|
|
|
+ ->where('source', 1)
|
|
|
+ ->pluck("id")
|
|
|
+ ->sort();
|
|
|
+
|
|
|
+ $contentFormData = [
|
|
|
+ 'description' => $imageUrlService->interceptImageUrl($request->description),
|
|
|
+ 'name' => $request->name,
|
|
|
+ 'files' => $files->implode(",") ?: null
|
|
|
+ ];
|
|
|
+
|
|
|
+ $containerContent = $container->content;
|
|
|
+ $containerContent->fill($contentFormData);
|
|
|
+ $contentChange = ModelChangeDetector::detector(ActionObjectType::CONTAINER_CONTENT, $containerContent);
|
|
|
+
|
|
|
+ if ($contentChange) {
|
|
|
+ $container->version++;
|
|
|
+ $changes = array_merge($changes, $contentChange);
|
|
|
+
|
|
|
+ ContainerContent::query()->create([
|
|
|
+ ...$contentFormData,
|
|
|
+ 'container_id' => $container->id,
|
|
|
+ 'created_by' => Auth::id(),
|
|
|
+ 'version' => $container->version,
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+
|
|
|
$container->save();
|
|
|
|
|
|
ActionRepository::createByContainer($container, ObjectAction::EDITED, objectChanges: $changes);
|