update image data from bank working
This commit is contained in:
parent
4f808ba017
commit
0e656e1920
5 changed files with 44 additions and 13 deletions
|
|
@ -1,8 +1,8 @@
|
||||||
Description: test
|
Description: nouvelle description
|
||||||
|
|
||||||
----
|
----
|
||||||
|
|
||||||
Tags: DA globale
|
Tags:
|
||||||
|
|
||||||
----
|
----
|
||||||
|
|
||||||
|
|
@ -10,7 +10,7 @@ Sort: 7
|
||||||
|
|
||||||
----
|
----
|
||||||
|
|
||||||
Uuid: cWXe3yDs2zcLLiQE
|
Uuid: PbMGJPIjFYxbbyhq
|
||||||
|
|
||||||
----
|
----
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,10 @@ Description:
|
||||||
|
|
||||||
----
|
----
|
||||||
|
|
||||||
Clientbriefimages: - file://cWXe3yDs2zcLLiQE
|
Clientbriefimages:
|
||||||
|
|
||||||
|
- file://PbMGJPIjFYxbbyhq
|
||||||
|
- file://STF67mX6eGsLsOGh
|
||||||
|
|
||||||
----
|
----
|
||||||
|
|
||||||
|
|
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 213 KiB |
|
|
@ -0,0 +1,17 @@
|
||||||
|
Description: test 2
|
||||||
|
|
||||||
|
----
|
||||||
|
|
||||||
|
Tags:
|
||||||
|
|
||||||
|
----
|
||||||
|
|
||||||
|
Sort: 8
|
||||||
|
|
||||||
|
----
|
||||||
|
|
||||||
|
Uuid: STF67mX6eGsLsOGh
|
||||||
|
|
||||||
|
----
|
||||||
|
|
||||||
|
Template: image
|
||||||
|
|
@ -29,17 +29,30 @@ return [
|
||||||
foreach ($data['imageUris'] as $imageUri) {
|
foreach ($data['imageUris'] as $imageUri) {
|
||||||
$imageData = json_decode($imageUri, true);
|
$imageData = json_decode($imageUri, true);
|
||||||
|
|
||||||
$source = page('materials')->file($imageData['uuid']);
|
$existingFile = $page->file($imageData['name']);
|
||||||
|
$source = null;
|
||||||
|
|
||||||
|
if (!$existingFile) {
|
||||||
|
try {
|
||||||
|
$source = page('materials')->file($imageData['uuid'])->copy($page);
|
||||||
|
} catch (\Throwable $th) {
|
||||||
|
$alerts[$source->name()] = $th->getMessage();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$allFiles = array_filter($allFiles, function ($uuid) use ($existingFile) {
|
||||||
|
return $uuid != $existingFile->uuid();
|
||||||
|
});
|
||||||
|
$source = $existingFile;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$copiedFile = $source->copy($page);
|
$updatedFile = $source->update([
|
||||||
$updatedFile = $copiedFile->update([
|
|
||||||
'description' => $imageData['description'],
|
'description' => $imageData['description'],
|
||||||
'tags' => $imageData['tags'],
|
'tags' => $imageData['tags'],
|
||||||
]);
|
]);
|
||||||
|
$allFiles[] = $updatedFile->uuid();
|
||||||
$allFiles[] = (string) $copiedFile->uuid();
|
} catch (\Throwable $th) {
|
||||||
} catch (Exception $e) {
|
$alert[$source->name()] = $th->getMessage();
|
||||||
$alerts[$source->name()] = $e->getMessage();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -106,8 +119,6 @@ return [
|
||||||
'clientBriefImages' => $allFiles
|
'clientBriefImages' => $allFiles
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new Exception(json_encode($allFiles), 1);
|
|
||||||
|
|
||||||
|
|
||||||
$images = [];
|
$images = [];
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue