123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- <?php
- namespace app\admin\model;
- use think\Model;
- class Recharorder extends Model
- {
-
-
- // 表名
- protected $name = 'rechar_order';
-
- // 自动写入时间戳字段
- protected $autoWriteTimestamp = 'int';
- // 定义时间戳字段名
- protected $createTime = 'createtime';
- protected $updateTime = 'updatetime';
- protected $deleteTime = false;
- // 追加属性
- protected $append = [
- 'purpose_text',
- 'status_text',
- 'pay_status_text'
- ];
-
-
- public function getPurposeList()
- {
- return ['1' => __('Purpose 1'), '2' => __('Purpose 2'), '3' => __('Purpose 3')];
- }
- public function getStatusList()
- {
- return ['0' => __('Status 0'), '1' => __('Status 1'), '2' => __('Status 2')];
- }
- public function getPayStatusList()
- {
- return ['1' => __('Pay_status 1'), '2' => __('Pay_status 2'), '3' => __('Pay_status 3')];
- }
- public function getPurposeTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['purpose']) ? $data['purpose'] : '');
- $list = $this->getPurposeList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getStatusTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
- $list = $this->getStatusList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getPayStatusTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['pay_status']) ? $data['pay_status'] : '');
- $list = $this->getPayStatusList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function user()
- {
- return $this->belongsTo('User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
- }
- public function video()
- {
- return $this->belongsTo('Video', 'video_id', 'id', [], 'LEFT')->setEagerlyType(0);
- }
- }
|