2 回答
TA贡献1812条经验 获得超5个赞
试试这样:
$teachers = User::with('teacherSubject')
->where(function($query) use($name) {
$query->where('first_name',$name);
->orWhereHas('teacherSubject', function ($query1) use($name){
$query1->where('subject',$name);
});
})
->get();
TA贡献1936条经验 获得超6个赞
你可以这样试试
$teachers = User::where(function($sub) use($name) {
$sub->where('first_name', $name)
->orWhereHas('teacherSubject', function($s) use($name) {
$s->where('subject', $name);
});
})whereHas('teacherSubject', function ($query) use($conditions){
$query->where($conditions);
})->with('teacherSubject')->get();
这$name是要搜索的第一个名字。
- 2 回答
- 0 关注
- 83 浏览
添加回答
举报