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'); + } }