<?php

namespace app\admin\model;

use support\Model;

/**
 * 悦享家会员认证模型
 * Class Members
 * @package app\api\model
 */
class UserAuth extends Model
{
    const UPDATED_AT = 'auth_update_time';

    const WAIT   = '0';
    const DONE   = '1';
    const RETURN = '2';
    const CANCEL = '3';
    const MEMBER_AUTH_STATUS = [
        self::WAIT   => '待审核',
        self::DONE   => '审核通过',
        self::RETURN => '审核驳回',
        self::CANCEL => '主动撤销'
    ];
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'user_auth';

    protected $dateFormat = 'U';

    /**
     * Notes:获取指定条件一列
     * @param int $status
     * @return array
     * User: yym
     * Date: 2022/8/4
     */
    public static function getListIds(int $status)
    {
        return static::select('auth_user_id')->where(['auth_status' => $status])->get()->toArray();
    }

    /**
     * Notes:更新会员认证信息
     * @param int $user_id
     * @param string $category
     * @param array $update
     * @return int
     * User: yym
     * Date: 2022/8/4
     */
    public static function updateAuth(int $user_id, string $category, array $update)
    {
        return static::where(['auth_user_id' => $user_id, 'auth_type' => $category])->update($update);
    }

    /**
     * Notes:插入记录
     * @param array $data
     * @return int
     * User: yym
     * Date: 2022/8/5
     */
    public static function insertData(array $data)
    {
        return static::insertGetId($data);
    }
}
