| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- <?php
- namespace app\admin\model\service\skill;
- use think\Model;
- class Applyskill extends Model
- {
-
-
- // 表名
- protected $name = 'service_apply_skill';
-
- // 自动写入时间戳字段
- protected $autoWriteTimestamp = 'integer';
- // 定义时间戳字段名
- protected $createTime = 'createtime';
- protected $updateTime = 'updatetime';
- protected $deleteTime = false;
- // 追加属性
- protected $append = [
- 'applytype_text',
- 'sex_text',
- 'edu_text',
- 'exper_text',
- 'state_text'
- ];
-
-
- public function getApplytypeList()
- {
- return ['0' => __('Applytype 0'), '1' => __('Applytype 1')];
- }
- public function getSexList()
- {
- return ['1' => __('Sex 1'), '0' => __('Sex 0')];
- }
- public function getEduList()
- {
- return ['0' => __('Edu 0'), '1' => __('Edu 1'), '2' => __('Edu 2'), '3' => __('Edu 3'), '4' => __('Edu 4'), '5' => __('Edu 5'), '6' => __('Edu 6')];
- }
- public function getExperList()
- {
- return ['0' => __('Exper 0'), '1' => __('Exper 1'), '2' => __('Exper 2'), '3' => __('Exper 3')];
- }
- public function getStateList()
- {
- return ['0' => __('State 0'), '1' => __('State 1'), '-1' => __('State -1')];
- }
- public function getApplytypeTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['applytype']) ? $data['applytype'] : '');
- $list = $this->getApplytypeList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getSexTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['sex']) ? $data['sex'] : '');
- $list = $this->getSexList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getEduTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['edu']) ? $data['edu'] : '');
- $list = $this->getEduList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getExperTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['exper']) ? $data['exper'] : '');
- $list = $this->getExperList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getStateTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['state']) ? $data['state'] : '');
- $list = $this->getStateList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public static function createTime($id)
- {
- $start = strtotime(date("Y-m-d",time()));
- $data['skill_id'] = $id;
- for($a = 0;$a<3;$a++)
- {
- $data['timetype'] = $a;
- for($b = 0;$b<48;$b++)
- {
- $data['number'] = $b;
- switch ($a) {
- case 1:
- $data['starttime'] = 1800*$b+$start+86400;
- $data['endtime'] = 1800*$b+$start+1799+86400;
- break;
- case 2:
- $data['starttime'] = 1800*$b+$start+172800;
- $data['endtime'] = 1800*$b+$start+1799+172800;
- break;
- case 0:
- default:
- $data['starttime'] = 1800*$b+$start;
- $data['endtime'] = 1800*$b+$start+1799;
- break;
- }
- $data['createtime'] = time();
- $data['changetime'] = time();
- $data['state'] = 0;
- db('service_skill_time')->insert($data);
- }
- }
- return true;
- }
- public function cate()
- {
- return $this->hasOne('Skillcate','id','skill_cate_id')->field('id,name');
- }
- public function category()
- {
- return $this->hasOne('app\admin\model\service\Category','id','category_id')->field('id,name');
- }
- }
|