models:
public function Fields()
{
$fields = parent::Fields();//原来models输出字段
$fields['parentComment'] = function (self $model){//‘parentComment’自定义输出字段
return ShopComment::find()->select('content')->where(['parent_id'=>$model->comment_id])->One();//列子是 查找评论父级数据;
};
return $fields;
}
controller:
$models = shopComment::find()->where(['comment_id'=>6])->One();
$models = $models->toArray();