12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- <?php
- namespace app\common\model;
- use think\Model;
- class ComjobsReport extends Model
- {
- // 设置字段信息
- protected $schema = [
- 'id' => 'int',
- 'comjobsid' => 'int',
- 'workerid' => 'int',
- 'agentid' => 'int',
- 'brokerid' => 'int',
- 'realname' => 'string',
- 'mobile' => 'string',
- 'idcard' => 'string',
- 'gender' => 'tinyint',
- 'arrivetime' => 'string',
- 'remark' => 'string',
- 'retremark' => 'string',
- 'status' => 'tinyint',
- 'createtime' => 'int'
- ];
-
- // 设置字段自动转换类型
- protected $type = [
- 'createtime' => 'timestamp:Y-m-d H:i'
- ];
- public function getStatusTextAttr($value,$data)
- {
- $status = [1=>'待审核', 2=>'待面试', 3=>'已入职', 4=>'无效报备'];
- return $status[$data['status']];
- }
-
- // public function getGenderTextAttr($value,$data)
- // {
- // $gender = [1=>'男', 2=>'女'];
- // return $gender[$data['gender']];
- // }
-
- public function getAgeTextAttr($value,$data)
- {
- $year = substr($data['idcard'], 6, 4);
- $monthDay = substr($data['idcard'], 10, 4);
- $age = date('Y') - $year;
- if ($monthDay > date('md')) {
- $age--;
- }
- return $age;
- }
-
- // 关联Comjobs
- public function comjobs()
- {
- return $this->hasOne(Comjobs::class, "id", "comjobsid");
- }
- // 关联Agent
- public function agent()
- {
- return $this->hasOne(Agent::class, "id", "agentid");
- }
-
- // 关联Broker
- public function broker()
- {
- return $this->hasOne(Broker::class, "id", "brokerid");
- }
-
- }
|