<?php

namespace app\model;

use DateTimeInterface;
use support\Model;

class GoodsEvaluate extends Model
{
    protected $table = 'goods_evaluate';

    protected $primaryKey = 'goods_evaluate_id';

    protected $dateFormat = 'U';

    const CREATED_AT = 'goods_evaluate_addtimes';

    const UPDATED_AT = null;

    public function serializeDate(DateTimeInterface $date)
    {
        return $date->format('Y-m-d H:i:s');
    }

    /**
     * @Desc 关联会员
     * @Author Gorden
     * @Date 2024/3/30 13:08
     *
     * @return \Illuminate\Database\Eloquent\Relations\HasOne
     */
    public function member()
    {
        return $this->hasOne(Member::class, 'member_id', 'join_evaluate_member_id');
    }

    /**
     * 关联Cert
     */
    public function cert()
    {
        return $this->hasOne(MemberCert::class, 'join_cert_member_id', 'join_evaluate_member_id');
    }

    public function info()
    {
        return $this->hasOne(MemberInfo::class, 'join_info_member_id', 'join_evaluate_member_id');
    }

    /**
     * @Desc 关联商品
     * @Author Gorden
     * @Date 2024/3/30 13:08
     *
     * @return \Illuminate\Database\Eloquent\Relations\HasOne
     */
    public function goods()
    {
        return $this->hasMany(Goods::class, 'goods_id', 'join_evaluate_goods_id');
    }

    public function good()
    {
        return $this->hasOne(Goods::class, 'goods_id', 'join_evaluate_goods_id');
    }

    /**
     * 关联订单
     */
    public function order()
    {
        return $this->hasOne(Order::class, 'order_id', 'join_evaluate_order_id');
    }
}