TP5 field() 方法 字段不显示

TP5 模型用field() 方法查询 有一个字段不显示

商品表 模型

/**
     * 定义商品和商品评论表之间得关系
     *
     * @return \think\model\relation\HasMany
     */
    public function goodsComment() {
        return $this->hasMany('MallComment', 'goods_id', 'id')->field('user_id,comment,comment_type,create_time');
    }

控制器使用

        $goodsInfo = Goods::goodsInfo($data['goods_id']);
        $goodsInfo->goodsComment()->order('create_time desc')->limit(0, 1)->select();

返回结果

   "goodsComment": [
            {
                "user_id": 33,
                "comment": "你好",
                "comment_type": 2,
                "user": {
                    "nickname": "XX",
                    "photo": "9f1cd8fd29d4b17ccd93b333ff558118.png"
                }
            },
            {
                "user_id": 33,
                "comment": "哈哈",
                "comment_type": 1,
                "user": {
                    "nickname": "XX",
                    "photo": "9f1cd8fd29d4b17ccd93b333ff558118.png"
                }
            }
        ]

返回结果中并没有create_time字段 并且 limit 和 order方法都失效了 数据库里是存在值得

https://img1.mukewang.com/5c8f3f6e00014f6a08000087.jpg

请大神指教下

蝴蝶不菲
浏览 1876回答 1
1回答

梦里花落0921

继承父模型隐藏create_time
打开App,查看更多内容
随时随地看视频慕课网APP