<?php

namespace App\Laravue\Models;

use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Laravel\Passport\HasApiTokens;
use Spatie\Permission\Traits\HasRoles;

/**
 * Class User
 *
 * @property string $name
 * @property string $email
 * @property string $password
 * @property Role[] $roles
 *
 * @method static User create(array $user)
 * @package App
 */
class Users extends Authenticatable
{
    use Notifiable, HasRoles, HasApiTokens;
    protected $table = "BackgroundUser";
    public $timestamps = false;

    public function getTypeAllToArray($userdata = []) {
        $check = '/^(1(([356789][0-9])|(47)))\d{8}$/';
        if($userdata == []){
            return "表单值不能为空";
        }
        if(!preg_match($check,$userdata['contacts_phone'])){
            return "手机号格式错误";
        }
         $userdata['password'] = sha1($userdata['password']);
        return $this->insertGetId($userdata);
    }
}