<?php
namespace app\common\model\orders;
use app\common\model\BaseModel;
use app\common\model\goods\Goods;

/**
 * @author 林海涛
 * @date 2024/7/17 下午5:23
 */
class OrderEffectiveLog extends BaseModel
{
    protected $name = 'order_effective_log';

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


    public function getEndEffectiveTimeAttr($value,$data)
    {
        return !empty($data['end_effective_time'])?date('Y-m-d H:i:s',$data['end_effective_time']):'';
    }

    public static function getEffectiveUnitTextAttr($value,$data)
    {
       $type = [1 => '天',2=> '小时'];
       return $type[$data['effective_unit']];
    }
}