'datetime', 'used_at' => 'datetime', ]; /** * 购买记录所属用户 */ public function user(): BelongsTo { return $this->belongsTo(User::class); } /** * 购买记录对应的商品(shopItem 别名,兼容婚姻系统调用) */ public function item(): BelongsTo { return $this->belongsTo(ShopItem::class, 'shop_item_id'); } /** * 购买记录对应的商品 */ public function shopItem(): BelongsTo { return $this->belongsTo(ShopItem::class, 'shop_item_id'); } /** * 判断周卡是否仍在有效期内 */ public function isAlive(): bool { if ($this->status !== 'active') { return false; } if ($this->expires_at && $this->expires_at->isPast()) { return false; } return true; } }