'string', 'version' => 'integer', 'modify_time' => 'integer', 'create_time' => 'integer', ]; public $incrementing = false; protected $fillable = ['id', 'guid', 'word', 'word_en', 'meaning', 'channal', 'language', 'owner', 'editor_id', 'editor_uid', 'create_time', 'modify_time']; /** 所属 channel(channal 列);studio 级术语为空 */ public function channel(): BelongsTo { return $this->belongsTo(Channel::class, 'channal', 'uid'); } /** 编辑者(人类用户)。editor_uid 对 user_infos.userid */ public function user(): BelongsTo { return $this->belongsTo(UserInfo::class, 'editor_uid', 'userid'); } /** 编辑者(AI 助手)。存量数据里 AI 写的行 editor_uid 直接是模型 */ public function aiModel(): BelongsTo { return $this->belongsTo(AiModel::class, 'editor_uid', 'uid'); } /** 协作者:人类授权代写的 AI 模型。此时 editor 是授权人 */ public function coEditor(): BelongsTo { return $this->belongsTo(AiModel::class, 'co_editor_uid', 'uid'); } /** 百科分类,按正文里出现的顺序 */ public function categories(): HasMany { return $this->hasMany(TermCategory::class, 'term_guid', 'guid')->orderBy('position'); } /** 实际方言:v2 写入的行库里是默认值 markdown */ public function effectiveContentType(): string { return $this->content_type ?: 'markdown'; } /** 乐观锁用的 ETag:v3 修改 +version,v2 修改只动 modify_time,两者都要算进去 */ public function etag(): string { return '"'.((int) $this->version).'.'.((int) $this->modify_time).'"'; } }