问题描述
我在这里有一个通过搜索检索产品的查询和另一个字段不等于零的查询.但是,我有一个字段 (srp),如果值不等于十进制零值,它应该返回数据.顺便说一下,srp 字段是一个价格值,这就是为什么它是十进制的.这是我的查询.
I have here a query that retrieves products with search and another query where fields are not equal to zero. However, I have one field (srp) where it should return data if values is not equal to a zero decimal value. The srp field is a price value by the way, that is why it's decimal. Here's my query.
public function render()
{
$searchTerm = '%' . $this->searchTerm . '%';
$products = Product::where(function($query) use ($searchTerm) {
return $query->where('code', 'like', $searchTerm)
->orWhere('name', 'like', $searchTerm)
->orWhere('description', 'like', $searchTerm);
}) ->where(function($query) {
return $query->where('qty_on_hand', '!=', 0)
->orWhereRaw('srp != FLOOR(0.00)');
})
->orderBy('name')
->paginate($this->amount);
$this->emit('productStore');
return view('livewire.load-in-stock-products', ['products' => $products]);
}
这是我要修复的代码行:->orWhereRaw('srp != FLOOR(0.00)');
Here's the line of code I'm trying to fix: ->orWhereRaw('srp != FLOOR(0.00)');
推荐答案
仅供参考,->orWhereRaw('srp != FLOOR(0.00)');
已经在工作.抱歉,因为我不知道.这是因为我正在考虑另一个领域,成本.同样,对上述问题的查询已经是正确答案.
FYI, the ->orWhereRaw('srp != FLOOR(0.00)');
is already working. Sorry as I didn't know. It was because I was looking at another field, cost. Again, the query on the question above is already the correct answer.
这篇关于如何在 Laravel Eloquent 中获取字段不等于零十进制值的数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!