laravel版本为5.4
1,有个这样的代码,如下
$this->model->with('article')->get()
2,现在执行的sql语句为
select * from article where..
我想sql语句能执行为
select id,title from user where..
请问如何实现
我试过的方法
$this->model->with(['user' => function($query){
$query->select('id','article');
}])->get()
OR
public function user() {
$query->belongTo(Article::class)->select('id', 'title');
}
都不行