, * summary?: string, * tpl_id: string|null, * pos_start: int|null, * pos_end: int|null, * quote_exact: string|null, * quote_prefix: string|null, * quote_suffix: string|null, * reply_count?: int, * sentence?: array{book: int, paragraph: int, word_start: int, word_end: int}, * editor: array{id: string, nickName: string, userName: string, realName: string, sn: int, avatar: string|null, roles: array|null}|null, * co_editor: array{id: string, nickName: string, userName: string, realName: string, sn: int, avatar: string|null, roles: array|null}|null, * abilities: array{update: bool, delete: bool, close: bool, reply: bool}, * created_at: string, * updated_at: string, * deleted_at: string|null * } */ public function toArray($request): array { $tombstone = $this->trashed(); return [ 'id' => (string) $this->id, 'target_type' => $this->res_type, 'target_id' => $this->res_id, 'parent_id' => $this->parent, 'type' => $this->type, 'severity' => $this->severity, 'score' => $this->score, 'status' => $this->status, 'title' => $tombstone ? null : $this->title, 'content' => $tombstone ? null : $this->content, 'content_type' => $this->effectiveContentType(), 'body' => $this->when($this->rendered !== null, fn () => $this->rendered['body']), 'summary' => $this->when($this->rendered !== null, fn () => $this->rendered['summary']), 'tpl_id' => $this->tpl_id, 'pos_start' => $this->pos_start, 'pos_end' => $this->pos_end, 'quote_exact' => $tombstone ? null : $this->quote_exact, 'quote_prefix' => $tombstone ? null : $this->quote_prefix, 'quote_suffix' => $tombstone ? null : $this->quote_suffix, 'reply_count' => $this->when($this->parent === null, fn () => (int) $this->reply_count), 'sentence' => $this->when(isset($this->sentence_book), fn () => [ 'book' => (int) $this->sentence_book, 'paragraph' => (int) $this->sentence_paragraph, 'word_start' => (int) $this->sentence_word_start, 'word_end' => (int) $this->sentence_word_end, ]), 'editor' => $this->actor($this->user, $this->aiModel), // AI 代写时的模型;人类自己写的、存量数据都为 null 'co_editor' => $this->coEditor ? $this->actor(null, $this->coEditor) : null, 'abilities' => $this->abilities ?? ['update' => false, 'delete' => false, 'close' => false, 'reply' => false], 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'deleted_at' => $this->deleted_at, ]; } }