Skip to content

Commit 327df7b

Browse files
committed
Add blueprint into data. Closes #6
1 parent 531d7e9 commit 327df7b

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/Entries/Entry.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public static function fromModel(Model $model)
1717
->date($model->date)
1818
->collection($model->collection)
1919
->data($model->data)
20+
->blueprint($model->data['blueprint'] ?? null)
2021
->published($model->published)
2122
->model($model);
2223
}
@@ -25,6 +26,12 @@ public function toModel()
2526
{
2627
$class = app('statamic.eloquent.entries.model');
2728

29+
$data = $this->data();
30+
31+
if ($this->blueprint && $this->collection()->entryBlueprints()->count() > 1) {
32+
$data['blueprint'] = $this->blueprint;
33+
}
34+
2835
return $class::findOrNew($this->id())->fill([
2936
'id' => $this->id() ?? $class::generateId(),
3037
'origin_id' => $this->originId(),
@@ -33,7 +40,7 @@ public function toModel()
3340
'uri' => $this->uri(),
3441
'date' => $this->hasDate() ? $this->date() : null,
3542
'collection' => $this->collectionHandle(),
36-
'data' => $this->data(),
43+
'data' => $data,
3744
'published' => $this->published(),
3845
'status' => $this->status(),
3946
]);

0 commit comments

Comments
 (0)