$user = UserAttribute::where('uid', $uid)->with([
'attribute' => function ($query) {$query->pluck('title');},
])->get();
上边这段代码可以执行,但是仍然把关联模型attribute里所有的字段都查询出来了,并不是想要的只查询title
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
可以在Model里select,但是id不能少,不然没有关联条件。