self::STATUS_FAILED, ]; protected $fillable = [ 'user_id', 'job_id', 'amount', 'status', 'created_at', 'updated_at', ]; public static $statusText = [ self::STATUS_FAILED=>'未领取', self::STATUS_SUCCESS=>'已领取', ]; public function user() { return $this->belongsTo(User::class); } public function scopeReceive($query) { return $query->where('status', static::STATUS_SUCCESS); } public function scopeWaitReceive($query) { $query->where('status', static::STATUS_FAILED); if ($hours = app_settings('distribution.quota_v1_receive', 0)) { return $query->where('created_at', '>', now()->subHours($hours)); } else { return $query; } } /** * 获取格式化售后金额 * * @return void */ public function getAmountFormatAttribute() { return trim_trailing_zeros(bcdiv($this->attributes['amount'], 100, 2)); } }