where(['id'=>$data['goods_id']])->value("image"); } public function getGoodsNameAttr($value, $data) { return db("goods")->where(['id'=>$data['goods_id']])->value("goods_name"); } public function getPriceAttr($value, $data) { return db("goods")->where(['id'=>$data['goods_id']])->value("coin_price"); } public function getAddTimeTextAttr($value, $data) { $value = $value ? $value : (isset($data['add_time']) ? $data['add_time'] : ''); return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value; } protected function setAddTimeAttr($value) { return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value); } }