我在Eloquent中有2个连接表,即主题和用户.
主题模型:
public function user() {
return $this->belongs_to('User');
}
Run Code Online (Sandbox Code Playgroud)
用户模型:
public function themes() {
return $this->has_many('Theme');
}
Run Code Online (Sandbox Code Playgroud)
我的Eloquent api电话如下:
return Response::eloquent(Theme::with('user')->get());
Run Code Online (Sandbox Code Playgroud)
它返回主题中的所有列(没关系),以及来自用户的所有列(不是很好).我只需要用户模型中的"用户名"列,如何限制查询?