'boolean', 'prize_level' => 'integer', 'payout' => 'integer', 'amount' => 'integer', ]; } // ─── 关联 ────────────────────────────────────────────────────────── /** * 关联的期次。 */ public function issue(): BelongsTo { return $this->belongsTo(LotteryIssue::class, 'issue_id'); } /** * 关联的购票用户。 */ public function user(): BelongsTo { return $this->belongsTo(User::class); } // ─── 业务方法 ────────────────────────────────────────────────────── /** * 返回本注选号的格式化字符串(用于备注和展示)。 * * @return string 如:红03 08 12 蓝4 */ public function numbersLabel(): string { return sprintf( '红%02d %02d %02d 蓝%d', $this->red1, $this->red2, $this->red3, $this->blue ); } /** * 是否已中奖。 */ public function isWon(): bool { return $this->prize_level > 0; } }