【发布时间】:2021-12-02 15:59:14
【问题描述】:
我写了一个查询,它会像这样在 laravel 中使用 exists() 函数返回真或假
$a=$item->conditions()->exists();
上面的查询工作正常,现在我想用where 条件扩展查询,这将检查status column should equal to the active 的天气,因为我正在编写以下代码,但它会抛出类似Call to a member function where() on boolean 的错误,请帮助我扩展查询以编写 where 条件。
$a=$item->conditions()->exists()->where('status','=','active');
注意:- conditions() -->从模型中返回一个ID
【问题讨论】:
-
使用
$item->conditions()->where('status', 'active')->exists();
标签: laravel laravel-migrations