$data */ public static function fromArray(array $data): self { return new self( commentableType: $data['commentable_type'], commentableId: $data['commentable_id'], content: $data['content'], authorName: $data['author_name'], rating: $data['rating'] ?? null, isApproved: $data['is_approved'] ?? false, adminReply: $data['admin_reply'] ?? null, ); } /** * @return array */ public function toArray(): array { return [ 'commentable_type' => $this->commentableType, 'commentable_id' => $this->commentableId, 'author_name' => $this->authorName, 'content' => $this->content, 'rating' => $this->rating, 'is_approved' => $this->isApproved, 'admin_reply' => $this->adminReply, ]; } }