]> _ Git - cubist_cms-back.git/commitdiff
wip #7868 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 9 Feb 2026 14:03:31 +0000 (15:03 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 9 Feb 2026 14:03:31 +0000 (15:03 +0100)
src/app/Magic/Traits/CustomDataSource.php

index e522c580a414eb54ebe4681f2cb12f0a96cfee98..856c6f6087ec63f05739b7803acaac37b277d938 100644 (file)
@@ -63,7 +63,7 @@ trait CustomDataSource
             $keys[] = $row[$pk];
         }
 
-        $toInsert = array_diff($keys, $existingKeys);
+        $toInsert = $keys;
         $toDelete = array_diff($existingKeys, $keys);
 
         $inserts = [];
@@ -73,8 +73,14 @@ trait CustomDataSource
             }
         }
 
+
         try {
-            static::insert($inserts);
+            foreach ($inserts as $key => $i) {
+                $id = [$pk => $key];
+                $data = $i;
+                unset($data[$pk]);
+                static::updateOrCreate($id, $data);
+            }
         } catch (\Exception $e) {
             $hadError = true;
             Log::error($e);
@@ -124,4 +130,5 @@ trait CustomDataSource
         touch(static::getDataLastChangeFile());
     }
 
+
 }