<?php

namespace app\common\model;

use think\Model;

class OutResume extends Model
{

    // 设置字段信息
    protected $schema = [
        'id'             => 'int',
        'brokerid'       => 'int',
        'name'           => 'string',
        'avatar'         => 'string',
        'mobile'         => 'string',
        'idcard'         => 'string',
        'gender'         => 'tinyint',
        'age'            => 'int',
        'jobintention'   => 'string',
        'address'        => 'string',
        'education'      => 'string',
        'createtime'     => 'int',
        'updatetime'     => 'int',
        'comment'        => 'string',
        'status'         => 'int',
        'confirm_status' => 'int',
    ];

    // 设置字段自动转换类型
    protected $type = [
        'createtime' => 'timestamp:Y-m-d H:i:s',
        'updatetime' => 'timestamp:Y-m-d H:i:s',
    ];

    static $status = [1 => '未跟进', 2 => '未面试', 3 => '面试通过', 4 => '面试未通过', 5 => '用户放弃', 6 => '已入职', 7 => '已离职'];
    static $gender = [1 => '男', 2 => '女'];
    static $confirm_status = [1 => '待核销', 2 => '核验通过', 3 => '核验失败'];

    public function getStatusTextAttr($value, $data)
    {
        return self::$status[$data['status']];
    }

    public function getConfirmStatusTextAttr($value, $data)
    {
        return self::$confirm_status[$data['confirm_status']];
    }

    public function getGenderTextAttr($value, $data)
    {
        return self::$gender[$data['gender']];
    }

    // 关联Worker
    public function broker()
    {
        return $this->hasOne(Broker::class, "id", "brokerid");
    }
}