<?php

namespace app\api\service;

use app\api\validate\UserValidate;
use app\model\project\User;
use app\model\project\User as userModel;
use app\Request;

class UserService
{

    public static function  getUserInfo($token)
    {

        $user = TokenService::verifyToken($token);
        if ($user===false)
        {
            return false;
        }
        $user = userModel::where(['token'=>$token,'is_del'=>0])
//            ->field('id,username,mobile,realname,token,role')
            ->with(['headico','zfb','userReal'])
            ->find();
        if (!$user)
        {
            return false;
        }

        return $user->toArray();
    }

    public static function updateUserInfo($filed,$value)
    {
        return User::where('id',\request()->userId)->update([$filed=>$value]);
    }


}