我有一个Laravel 5.1应用程序,并且在数字比较中遇到'where'问题。 具体我试图做的事:Laravel数字比较在'哪里'不起作用
{{\App\Items::all()->where('paid_price','>',0)->count()}}
paid_price的SQL '类型' 是 '十进制(8,2)'。 有几个Item行其中paid_price实际上大于零,但上面的代码只是产量为0.像下面这些不依赖于数值比较的东西很好用 - 你能给我一些关于为什么>不起作用?非常感谢
{{\App\Items::all()->where('other_column','some_value')->count()}}
为我的项目类的代码如下:
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Items extends Model {
protected $fillable =['gateway','paid_price','payment_date','auth_date','charge_date','refunded_date'];
protected $dates = ['payment_date','auth_date','charge_date','refunded_date'];
public function setUserIdAttribute($value)
{
$this->attributes['user_id'] = $value ?: null;
}
}