<?php

namespace app\common\model\odd_job;

use think\Model;
use think\model\concern\SoftDelete;

class UserModel extends Model
{
    use SoftDelete;
    protected $deleteTime = 'deletetime';
    protected $defaultSoftDelete = 0;

    protected $connection = 'odd_job';

    //设置表名
    protected $name = 'user';

    // 设置字段自动转换类型
    protected $type = [
        'bankcard'   => 'json',
        'createtime' => 'timestamp:Y-m-d H:i:s',
        'emp_time'   => 'json',
        'com_cate'   => 'json',
        'work_place' => 'json',
        'user_tags'  => 'json',
        'skill_cert' => 'json',
    ];
    protected $jsonAssoc = true;

    public function getStatusTextAttr($value, $data)
    {
        $status = [1 => '待审核', 2 => '已通过', 3 => '未通过'];
        return $status[$data['status']];
    }

    public function getIsvipTextAttr($value, $data)
    {
        $isvip = [1 => '否', 2 => '是'];
        return $isvip[$data['isvip']];
    }

    public function getAuthstatusTextAttr($value, $data)
    {
        $authstatus = [1 => '待认证', 2 => '待审核', 3 => '已认证'];
        return $authstatus[$data['authstatus']];
    }

    public function getFollowstatusTextAttr($value, $data)
    {
        $followstatus = [1 => '未跟进', 2 => '未面试', 3 => '面试通过', 4 => '面试未通过', 5 => '用户放弃', 6 => '已入职', 7 => '已离职'];
        return $followstatus[$data['followstatus']];
    }

    public function getEducationTextAttr($value, $data)
    {
        $education = ['' => '', 1 => '初中及以下', 2 => '高中', 3 => '中技', 4 => '中专', 5 => '大专', 6 => '本科', 7 => '硕士', 8 => '博士'];
        return $education[$data['education']];
    }

    public function getWorkerTextAttr($value, $data)
    {
        $experience = ['' => '', 1 => '无经验', 2 => '一年以下', 3 => '1-3年', 4 => '3-5年', 5 => '5-10年', 6 => '10年以上'];
        return $experience[$data['workexperience']];
    }
}