From e81887034c745877619836806f27e7746ff8a7f8 Mon Sep 17 00:00:00 2001 From: lkddi Date: Sun, 1 Mar 2026 19:05:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20WeddingCeremony=20?= =?UTF-8?q?=E6=A8=A1=E5=9E=8B=EF=BC=9A=E8=A1=A5=E5=85=A8=20fillable/casts?= =?UTF-8?q?=20=E5=8F=8A=E5=85=B3=E8=81=94=E5=85=B3=E7=B3=BB=EF=BC=8C?= =?UTF-8?q?=E8=A7=A3=E5=86=B3=E6=89=B9=E9=87=8F=E8=B5=8B=E5=80=BC=E6=8A=A5?= =?UTF-8?q?=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Models/WeddingCeremony.php | 77 +++++++++++++++++++++++++++++++++- 1 file changed, 76 insertions(+), 1 deletion(-) diff --git a/app/Models/WeddingCeremony.php b/app/Models/WeddingCeremony.php index a3927a0..ed23aa0 100644 --- a/app/Models/WeddingCeremony.php +++ b/app/Models/WeddingCeremony.php @@ -1,10 +1,85 @@ + */ + protected $fillable = [ + 'marriage_id', + 'tier_id', + 'total_amount', + 'payer_type', + 'groom_amount', + 'partner_amount', + 'ceremony_type', + 'ceremony_at', + 'status', + 'online_count', + 'claimed_count', + 'claimed_amount', + 'expires_at', + ]; + + /** + * 字段类型转换。 + * + * @return array + */ + protected function casts(): array + { + return [ + 'ceremony_at' => 'datetime', + 'expires_at' => 'datetime', + 'total_amount' => 'integer', + 'groom_amount' => 'integer', + 'partner_amount' => 'integer', + 'online_count' => 'integer', + 'claimed_count' => 'integer', + 'claimed_amount' => 'integer', + ]; + } + + /** + * 关联婚姻记录。 + */ + public function marriage(): BelongsTo + { + return $this->belongsTo(Marriage::class); + } + + /** + * 关联婚礼档位。 + */ + public function tier(): BelongsTo + { + return $this->belongsTo(WeddingTier::class, 'tier_id'); + } + + /** + * 关联红包领取记录。 + */ + public function claims(): HasMany + { + return $this->hasMany(WeddingEnvelopeClaim::class, 'ceremony_id'); + } }