self::STATUS_INVALID_STRING, self::STATUS_WAIT_PAY => self::STATUS_WAIT_PAY_STRING, self::STATUS_ALREADY_PAID => self::STATUS_ALREADY_PAID_STRING, self::STATUS_DELIVERING => self::STATUS_DELIVERING_STRING, self::STATUS_COMPLETED => self::STATUS_COMPLETED_STRING, ]; } // 关联订单商品 public function orderGoods() { return $this->hasMany(ShopOrderGoods::class, 'order_id'); } /** * 获取订单 及 订单商品列表 */ public static function getOrderAndOrderGoodsList($condition) { return static::with('orderGoods')->where($condition)->orderBy('id', 'desc')->get(); } /** * 获取订单数量 */ public static function countOrder($condition) { $n = static::where($condition)->count(); return $n ? $n : 0; } public function getAddTimeAttribute($value) { return Carbon::createFromTimestamp(strtotime($value)) // Leave this part off if you want to keep the property as // a Carbon object rather than always just returning a string ->toDateTimeString() ; } }