在Eloquent中,我想生成此查询:
SELECT * FROM table WHERE a=1 AND ( b=2 OR c=3 );
Run Code Online (Sandbox Code Playgroud)
但我似乎正在生成此查询:
SELECT * FROM table WHERE a=1 AND b=2 OR c=3;
Run Code Online (Sandbox Code Playgroud)
这是我的实现和代码:
$result = Model::aIsOne()->bIsTwoOrCIsThree()->get();
Run Code Online (Sandbox Code Playgroud)
Model 包含:
function scopeAIsOne($query) {
return $query->where('a', 1);
}
function scopeBIsTwoOrCIsThree($query) {
return $query->where('b', 2)->orWhere('c', 3);
}
Run Code Online (Sandbox Code Playgroud)
谢谢你的帮助.我搜索过包括Advanced Wheres在内的文档无济于事.