我有一個表,我正在運行搜索。富。我想檢查搜索詞是否像表中的一堆不同的字段。但我希望結果被強制爲「積極」。如何強制拉拉維爾集合的where子句5
我使用Laravel 5.0
$foos = DB::table('foo')
->where('name', 'LIKE', '%' . $query . '%')
->orWhere('description', 'LIKE', '%' . $query . '%')
->orWhere('address_city', 'LIKE', '%' . $query . '%')
->orWhere('short_description', 'LIKE', '%' . $query . '%')
->orWhere('interview', 'LIKE', '%' . $query . '%')
->get();
$foos = $foos->where('active', true)->get();
把' - >在哪裏( '主動',真)'之前,你的第一個'where'不起作用? –
就是這樣。謝謝 –
對我來說似乎很奇怪,你希望在返回的'Collection'上有一個where子句,而不是在數據庫查詢中增加另一個where子句。 –