123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- <?php
- namespace app\admin\model;
- use think\Model;
- class UniversityEventApply extends Model
- {
-
-
- // 表名
- protected $table = 'university_event_apply';
-
- // 自动写入时间戳字段
- protected $autoWriteTimestamp = false;
- // 定义时间戳字段名
- protected $createTime = false;
- protected $updateTime = false;
- protected $deleteTime = false;
- // 追加属性
- protected $append = [
- 'status_text',
- 'is_pay_text',
- 'pay_time_text',
- 'cancel_time_text',
- 'create_time_text',
- 'update_time_text'
- ];
-
-
- public function getStatusList()
- {
- return ['1' => __('Status 1'), '0' => __('Status 0'), '2' => __('Status 2')];
- }
- public function getIsPayList()
- {
- return ['1' => __('Is_pay 1'), '0' => __('Is_pay 0')];
- }
- public function getStatusTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
- $list = $this->getStatusList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getIsPayTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['is_pay']) ? $data['is_pay'] : '');
- $list = $this->getIsPayList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getPayTimeTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['pay_time']) ? $data['pay_time'] : '');
- return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
- }
- public function getCancelTimeTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['cancel_time']) ? $data['cancel_time'] : '');
- return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
- }
- public function getCreateTimeTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['create_time']) ? $data['create_time'] : '');
- return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
- }
- public function getUpdateTimeTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['update_time']) ? $data['update_time'] : '');
- return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
- }
- protected function setPayTimeAttr($value)
- {
- return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
- }
- protected function setCancelTimeAttr($value)
- {
- return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
- }
- protected function setCreateTimeAttr($value)
- {
- return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
- }
- protected function setUpdateTimeAttr($value)
- {
- return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
- }
- public function user()
- {
- return $this->belongsTo('User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
- }
- public function events()
- {
- return $this->belongsTo('app\admin\model\university\Event', 'event_id', 'id', [], 'LEFT')->setEagerlyType(0);
- }
- }
|