如何编写具有多个条件的 laravel 模型

how to write laravel model having with multi conditions

我们可以这样写 orwhere 子句:

$model::select('*')->where(function($query {
   $query->orWhere()
         ->orWhere();
})

如何不使用原始方式编写下面的 orhaving 子句:

$model::havingRaw('(count > 10 and count <20) or (xxx and xxx)')

感谢

您可以使用代码段

$query->orHaving('count', '>', 10)->orHaving('count', '<', 20);

还不能嵌套 having 子句。你必须使用原始 SQL.

已建议此功能:https://github.com/laravel/ideas/issues/999