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']]; } }