Users.php 987 Bytes
Newer Older
冯超鹏's avatar
冯超鹏 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
<?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);
    }
}