<?php
// +----------------------------------------------------------------------
// | onezan-admin 快速开发的管理平台
// +----------------------------------------------------------------------
// | 官方网址：https://www.onezan.cn
// +----------------------------------------------------------------------
// | onezan团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: 543885307@qq.com
// +----------------------------------------------------------------------
namespace app\repository\user;

use app\model\UserVerifyProfile;
use app\repository\BaseRepository;


/**
 * User Verify Profile Repository
 * @package app\repository\user
 */
class UserVerifyProfileRepository extends BaseRepository
{

    /**
     * 根据用户ID查找认证资料
     * @param int $userId 用户ID
     * @return UserVerifyProfile|null
     */
    public function findByUserId(int $userId): ?UserVerifyProfile
    {
        $profile = UserVerifyProfile::where('user_id', $userId)->find();
        return $profile instanceof UserVerifyProfile ? $profile : null;
    }


    /**
     * 创建空的认证资料模型
     * @param int $userId
     * @return UserVerifyProfile
     */
    public function newModel(int $userId): UserVerifyProfile
    {
        $profile = new UserVerifyProfile();
        $profile->user_id = $userId;
        return $profile;
    }
}