123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <?php
- namespace app\common\model;
- use think\Model;
- class OutRecruitReport extends Model
- {
- // 设置字段信息
- protected $schema = [
- 'id' => 'int',
- 'recruit_id' => 'int',
- 'workerid' => 'int',
- 'agentid' => 'int',
- 'brokerid' => 'int',
- 'realname' => 'string',
- 'mobile' => 'string',
- 'idcard' => 'string',
- 'arrivetime' => 'string',
- 'status' => 'tinyint',
- 'remark' => 'string',
- 'retremark' => 'string',
- '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 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 recruit()
- {
- return $this->hasOne(OutRecruit::class, "id", "recruit_id");
- }
- // 关联Agent
- public function worker()
- {
- return $this->hasOne(Worker::class, "id", "agentid");
- }
- // 关联Agent
- public function agent()
- {
- return $this->hasOne(Agent::class, "id", "agentid");
- }
- // 关联Broker
- public function broker()
- {
- return $this->hasOne(Broker::class, "id", "brokerid");
- }
- }
|