Failed calling ::jsonSerialize()

浏览:834 发布日期:2019/03/21 分类:求助交流
Failed calling app\services\model\Domain::jsonSerialize()
* @access protected
* @param mixed $data 要处理的数据
* @return mixed
* @throws \Exception
*/
protected function output($data)
{
try {
// 返回JSON数据格式到客户端 包含状态信息
$data = json_encode($data, $this->options['json_encode_param']);

if ($data === false) {
throw new \InvalidArgumentException(json_last_error_msg());
}

return $data;
} catch (\Exception $e) {
if ($e->getPrevious()) {
throw $e->getPrevious();



就是我想在获取器里面返回的不是ID,而是ID对应的用户名。。。

public function getOwnerIdAttr($value) {
$data = Member::get(['id'=>$value]);
return $data['username'];
}

我现在改成这样可以用,但是能不能用模型关联来做,,,感觉这个模型关联好不清楚呀。。。
新手上路,请指点
最佳答案
评论( 相关
后面还有条评论,点击查看>>