123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- <?php
- namespace app\common\model\commission;
- use think\Model;
- class Identity extends Model
- {
- protected $name = 'shopro_commission_identity';
-
- // 开启自动写入时间戳字段
- protected $autoWriteTimestamp = 'int';
-
- // 定义时间戳字段名
- protected $createTime = 'createtime';
- protected $updateTime = 'updatetime';
- // 追加属性
- protected $append = [
- 'status_text'
- ];
- // 状态
- const STATUS_DISABLED = 0;
- const STATUS_ENABLED = 1;
- public function getStatusList()
- {
- return [
- self::STATUS_DISABLED => '禁用',
- self::STATUS_ENABLED => '启用'
- ];
- }
- public function getStatusTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
- $list = $this->getStatusList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- /**
- * 获取启用的身份列表
- */
- public static function getEnabledList()
- {
- return self::where('status', self::STATUS_ENABLED)
- ->order('weigh asc, id asc')
- ->select();
- }
- }
|