枚举类型说明
什么是枚举
枚举是一种数据类型,它定义了一组可选的值。这些值通常表示一个特定的状态或选项。在Laravel中,我们可以使用枚举来定义模型的字段,以限制其接受的值。
为什么使用枚举?
使用枚举有一下几个有点:
- 提高代码可读性: 使用枚举可以明确指定字段的有效选项,使代码更易于阅读和理解
- 数据一致性: 通过使用枚举,我们可以限制字段接收的值,确保数据的一致性
- 避免硬编码: 使用枚举可以避免在代码中硬编码字符串或数字,提高代码的可维护性和科扩展性
项目枚举数据说明
AccountStatus 账户状态
| value | description |
|---|
| enabled | 正常 |
| freeze | 冻结 |
AccountLogType 收支类型
| value | description |
|---|
| income | 收入 |
| expend | 支出 |
AccountLogClassify 收支类别
| value | description |
|---|
| delivery_salary | 配送薪资 |
| delivery_award | 配送奖励 |
| withdraw | 提现 |
| withdraw_service_fee | 提现手续费 |
PayType 支付类型
| value | description |
|---|
| wechat | 微信 |
| alipay | 支付宝 |
| cash | 现金 |
PayStatus 支付状态
| value | description |
|---|
| paying | 支付中 |
| paid | 已支付 |
| refunding | 退款中 |
| refunded | 已退款 |
| cancelled | 交易取消 |
TradeType 交易类型
| value | description |
|---|
| order_goods | 外卖订单 |
| order_group | 团购订单 |
| refund | 退款 |
| other | 其他 |