self::STATUS_PENDING, ]; /** * @var array */ protected $fillable = [ 'sn', 'order_id', 'after_sale_id', 'amount', 'status', 'reason', 'failed_reason', ]; /** * @var array */ public static $statusTexts = [ self::STATUS_PENDING => '待处理', self::STATUS_SUCCESS => '成功', self::STATUS_FAILED => '失败', ]; /** * 只查询待退款的记录 */ public function scopePending($query) { return $query->where('status', static::STATUS_PENDING); } /** * 此退款记录所属的订单 */ public function order() { return $this->belongsTo(Order::class); } public function afterSale() { return $this->belongsTo(AfterSale::class); } }