hasOne('UserCollect', 'market_id', 'id', [], 'LEFT')->where('user_id', Auth::instance()->getUser()['id']); } //产品 public function products() { $header = Request::instance()->header('Accept-Language'); $lan = !empty($header)? substr($header, 0, 2):'zh' ; return $this->hasOne('ProductLists', 'id', 'product_id', [], 'LEFT')->field('id,'.$lan .'_name as name,thum'); } //寄售 public function producttransfer() { $order = 'price asc'; if(input('post.sort') == 1) $order = 'price desc'; return $this->hasMany('ProductTransfer', 'product_id', 'product_id', [], 'LEFT')->order($order)->where('status', self::Normal); } public function getCreateTimeTextAttr($value, $data) { $value = $value ? $value : (isset($data['create_time']) ? $data['create_time'] : ''); return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value; } public function getUpdateTimeTextAttr($value, $data) { $value = $value ? $value : (isset($data['update_time']) ? $data['update_time'] : ''); return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value; } protected function setCreateTimeAttr($value) { return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value); } protected function setUpdateTimeAttr($value) { return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value); } }