<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class UserExtra extends Model
{
    
    protected $primaryKey = "uid";
    
    protected $table = "user_extra";
    
    public static function findByUdid($udid) 
    {
        return self::where("udid", $udid)->first();
    }
    
    public static function getPasswordStrength($password)
    {
        if (empty($password)) {
            return 0;
        }
        
        $pattern = "/^[0-9]+$/";
        if (preg_match($pattern, $password)) {
            return 1;
        }
        
        $pattern = "/^[a-zA-Z]+$/";
        if (preg_match($pattern, $password)) {
            return 1;
        }
        
        $pattern = "/^[0-9a-zA-Z]+$/";
        if (preg_match($pattern, $password)) {
            return 2;
        }
        
        return 3;
    }
}
