<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

/**
 * App\Models\UserVipRecord.
 *
 * @property int                        $id         id
 * @property int                        $combo_id   套餐ID
 * @property int                        $valid_day  有效天数
 * @property int                        $pay_id     支付ID
 * @property \Illuminate\Support\Carbon $updated_at 删除时间
 * @property string                     $deleted_at 删除时间
 * @property \Illuminate\Support\Carbon $created_at 创建时间
 *
 * @method static \Illuminate\Database\Eloquent\Builder|UserVipRecord newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|UserVipRecord newQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|UserVipRecord query()
 * @method static \Illuminate\Database\Eloquent\Builder|UserVipRecord whereComboId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|UserVipRecord whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|UserVipRecord whereDeletedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|UserVipRecord whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|UserVipRecord wherePayId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|UserVipRecord whereUpdatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|UserVipRecord whereValidDay($value)
 *
 * @mixin \Eloquent
 *
 * @property int                       $user_id 用户ID
 * @property \App\Models\VipCombo|null $combo
 * @property \App\Models\User|null     $user
 *
 * @method static \Illuminate\Database\Eloquent\Builder|UserVipRecord whereUserId($value)
 *
 * @property \App\Models\Pay|null $pay
 * @property int|null             $status 状态 1- 支付成功
 *
 * @method static \Illuminate\Database\Eloquent\Builder|UserVipRecord whereStatus($value)
 */
class UserVipRecord extends Model
{
    use HasFactory;

    protected function serializeDate(\DateTimeInterface $date)
    {
        return $date->format($this->dateFormat ?: 'Y-m-d H:i:s');
    }

    public function user()
    {
        return $this->belongsTo(User::class, 'user_id', 'id');
    }

    public function combo()
    {
        return $this->belongsTo(VipCombo::class, 'combo_id', 'id');
    }

    public function pay()
    {
        return $this->belongsTo(Pay::class, 'pay_id');
    }
}
