123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- <?php
- namespace app\admin\model;
- use think\Model;
- class Lave extends Model
- {
-
-
- // 表名
- protected $name = 'lave';
-
- // 自动写入时间戳字段
- protected $autoWriteTimestamp = 'int';
- // 定义时间戳字段名
- protected $createTime = 'createtime';
- protected $updateTime = false;
- protected $deleteTime = false;
- // 追加属性
- protected $append = [
- 'is_open_text',
- 'is_ticket_text',
- 'paid_text',
- 'pay_type_text',
- 'paytime_text',
- 'type_text'
- ];
-
-
- public function getIsOpenList()
- {
- return ['0' => __('Is_open 0'), '1' => __('Is_open 1')];
- }
- public function getIsTicketList()
- {
- return ['0' => __('Is_ticket 0'), '1' => __('Is_ticket 1')];
- }
- public function getPaidList()
- {
- return ['0' => __('Paid 0'), '1' => __('Paid 1')];
- }
- public function getPayTypeList()
- {
- return ['0' => __('Pay_type 0'), '1' => __('Pay_type 1'), '2' => __('Pay_type 2'), '3' => __('Pay_type 3'), '4' => __('Pay_type 4')];
- }
- public function getTypeList()
- {
- return ['0' => __('Type 0'), '1' => __('Type 1')];
- }
- public function getIsOpenTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['is_open']) ? $data['is_open'] : '');
- $list = $this->getIsOpenList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getIsTicketTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['is_ticket']) ? $data['is_ticket'] : '');
- $list = $this->getIsTicketList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getPaidTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['paid']) ? $data['paid'] : '');
- $list = $this->getPaidList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getPayTypeTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['pay_type']) ? $data['pay_type'] : '');
- $list = $this->getPayTypeList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getPaytimeTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['paytime']) ? $data['paytime'] : '');
- return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
- }
- public function getTypeTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['type']) ? $data['type'] : '');
- $list = $this->getTypeList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- protected function setPaytimeAttr($value)
- {
- return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
- }
- }
|