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) {
|
||||
$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 {
|
||||
$copiedFile = $source->copy($page);
|
||||
$updatedFile = $copiedFile->update([
|
||||
$updatedFile = $source->update([
|
||||
'description' => $imageData['description'],
|
||||
'tags' => $imageData['tags'],
|
||||
]);
|
||||
|
||||
$allFiles[] = (string) $copiedFile->uuid();
|
||||
} catch (Exception $e) {
|
||||
$alerts[$source->name()] = $e->getMessage();
|
||||
$allFiles[] = $updatedFile->uuid();
|
||||
} catch (\Throwable $th) {
|
||||
$alert[$source->name()] = $th->getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -106,8 +119,6 @@ return [
|
|||
'clientBriefImages' => $allFiles
|
||||
]);
|
||||
}
|
||||
|
||||
throw new Exception(json_encode($allFiles), 1);
|
||||
|
||||
|
||||
$images = [];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue