123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- <?php
- namespace app\admin\model\training;
- use think\Model;
- class Volunteer extends Model
- {
-
-
- // 表名
- protected $name = 'volunteer';
-
- // 自动写入时间戳字段
- protected $autoWriteTimestamp = 'int';
- // 定义时间戳字段名
- protected $createTime = 'createtime';
- protected $updateTime = 'updatetime';
- protected $deleteTime = false;
- // 追加属性
- protected $append = [
- 'sex_text',
- 'is_vol_text',
- 'is_experience_text',
- 'work_week_text',
- 'status_text'
- ];
-
-
- public function getSexList()
- {
- return ['0' => __('Sex 0'), '1' => __('Sex 1')];
- }
- public function getIsVolList()
- {
- return ['0' => __('Is_vol 0'), '1' => __('Is_vol 1')];
- }
- public function getIsExperienceList()
- {
- return ['0' => __('Is_experience 0'), '1' => __('Is_experience 1')];
- }
- public function getWorkWeekList()
- {
- return ['1' => __('Work_week 1'), '2' => __('Work_week 2'), '3' => __('Work_week 3'), '4' => __('Work_week 4'), '5' => __('Work_week 5'), '6' => __('Work_week 6'), '7' => __('Work_week 7')];
- }
- public function getStatusList()
- {
- return ['0' => __('Status 0'), '1' => __('Status 1'), '-1' => __('Status -1')];
- }
- public function getSexTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['sex']) ? $data['sex'] : '');
- $list = $this->getSexList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getIsVolTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['is_vol']) ? $data['is_vol'] : '');
- $list = $this->getIsVolList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getIsExperienceTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['is_experience']) ? $data['is_experience'] : '');
- $list = $this->getIsExperienceList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getWorkWeekTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['work_week']) ? $data['work_week'] : '');
- $valueArr = explode(',', $value);
- $list = $this->getWorkWeekList();
- return implode(',', array_intersect_key($list, array_flip($valueArr)));
- }
- public function getStatusTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
- $list = $this->getStatusList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- protected function setWorkWeekAttr($value)
- {
- return is_array($value) ? implode(',', $value) : $value;
- }
- }
|