【发布时间】:2016-12-03 12:43:19
【问题描述】:
我有一个 Laravel 5.1 应用程序,但在使用数字比较的“位置”时遇到了问题。 具体来说,我正在尝试做:
{{\App\Items::all()->where('paid_price','>',0)->count()}}
paid_price 的 SQL 'type' 是 'decimal(8,2)'。 有几个 Item 行的paid_price 实际上大于零,但上面的代码只产生 0。像下面这样不依赖数字比较的东西工作得很好——你能给我一些关于为什么 > 不不行吗?非常感谢
{{\App\Items::all()->where('other_column','some_value')->count()}}
我的 Items 类的代码如下:
<?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;
}
}
【问题讨论】:
标签: php sql laravel laravel-5 laravel-5.1