+
+ public static function fromEntity(Entity $entity): self
+ {
+ $attrs = $entity->getAttributes();
+ $simple = new self();
+
+ $simple->id = $attrs['id'];
+ $simple->type = $entity->getMorphClass();
+ $simple->owned_by = $attrs['owned_by'] ?? 0;
+ $simple->book_id = $attrs['book_id'] ?? null;
+ $simple->chapter_id = $attrs['chapter_id'] ?? null;
+
+ return $simple;
+ }