123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191 |
- <?php
- namespace app\admin\model;
- use think\Model;
- class UserPower extends Model
- {
-
-
- // 表名
- protected $name = 'user_power';
-
- // 自动写入时间戳字段
- protected $autoWriteTimestamp = false;
- // 定义时间戳字段名
- protected $createTime = false;
- protected $updateTime = false;
- protected $deleteTime = false;
- // 追加属性
- protected $append = [
- 'private_messages_text',
- 'speak_text',
- 'speak_time_text',
- 'recharge_text',
- 'raffle_text',
- 'give_gift_text',
- 'transfer_text',
- 'payorder_text',
- 'attire_text',
- 'noble_text',
- 'withdraw_text'
- ];
-
-
- public function getPrivateMessagesList()
- {
- return ['0' => __('Private_messages 0'), '1' => __('Private_messages 1'), '2' => __('Private_messages 2')];
- }
- public function getSpeakList()
- {
- return ['0' => __('Speak 0'),'1' => __('Speak 1'),'2' => __('Speak 2')];
- }
- public function getRechargeList()
- {
- return ['0' => __('Recharge 0'), '1' => __('Recharge 1')];
- }
- public function getRaffleList()
- {
- return ['0' => __('Raffle 0'), '1' => __('Raffle 1')];
- }
- public function getGiveGiftList()
- {
- return ['0' => __('Give_gift 0'), '1' => __('Give_gift 1')];
- }
- public function getTransferList()
- {
- return ['0' => __('Transfer 0'), '1' => __('Transfer 1')];
- }
- public function getPayorderList()
- {
- return ['0' => __('Payorder 0'), '1' => __('Payorder 1')];
- }
- public function getAttireList()
- {
- return ['0' => __('Attire 0'), '1' => __('Attire 1')];
- }
- public function getNobleList()
- {
- return ['0' => __('Noble 0'), '1' => __('Noble 1')];
- }
- public function getWithdrawList()
- {
- return ['0' => __('Withdraw 0'), '1' => __('Withdraw 1')];
- }
- public function getPrivateMessagesTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['private_messages']) ? $data['private_messages'] : '');
- $list = $this->getPrivateMessagesList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getSpeakTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['speak']) ? $data['speak'] : '');
- $list = $this->getSpeakList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getSpeakTimeTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['speak_time']) ? $data['speak_time'] : '');
- return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
- }
- public function getRechargeTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['recharge']) ? $data['recharge'] : '');
- $list = $this->getRechargeList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getRaffleTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['raffle']) ? $data['raffle'] : '');
- $list = $this->getRaffleList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getGiveGiftTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['give_gift']) ? $data['give_gift'] : '');
- $list = $this->getGiveGiftList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getTransferTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['transfer']) ? $data['transfer'] : '');
- $list = $this->getTransferList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getPayorderTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['payorder']) ? $data['payorder'] : '');
- $list = $this->getPayorderList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getAttireTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['attire']) ? $data['attire'] : '');
- $list = $this->getAttireList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getNobleTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['noble']) ? $data['noble'] : '');
- $list = $this->getNobleList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getWithdrawTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['withdraw']) ? $data['withdraw'] : '');
- $list = $this->getWithdrawList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- protected function setSpeakTimeAttr($value)
- {
- return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
- }
- public function user()
- {
- return $this->belongsTo('User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
- }
- }
|