diff --git a/src/Entries/Entry.php b/src/Entries/Entry.php index 27fc5ff9..5b1fefbb 100644 --- a/src/Entries/Entry.php +++ b/src/Entries/Entry.php @@ -41,8 +41,7 @@ public function toModel() $data['blueprint'] = $this->blueprint; } - return $class::findOrNew($this->id())->fill([ - 'id' => $this->id(), + $attributes = [ 'origin_id' => $this->origin()?->id(), 'site' => $this->locale(), 'slug' => $this->slug(), @@ -54,7 +53,13 @@ public function toModel() 'status' => $this->status(), 'updated_at' => $this->lastModified(), 'order' => $this->order(), - ]); + ]; + + if ($id = $this->id()) { + $attributes['id'] = $id; + } + + return $class::findOrNew($id)->fill($attributes); } public function model($model = null) diff --git a/tests/Entries/EntryTest.php b/tests/Entries/EntryTest.php index a3f315e4..7baad714 100644 --- a/tests/Entries/EntryTest.php +++ b/tests/Entries/EntryTest.php @@ -44,7 +44,6 @@ public function it_saves_to_entry_model() 'published' => false, 'status' => 'draft', 'origin_id' => null, - 'id' => null, 'order' => null, ]);