<?php
namespace app\admin\model;

use think\Model;


class Admins extends Model
{
    //检测token
    function checktoken($token){
        $user = db('admins')->where('token', $token)->find();
        if(!empty($user)){
            $time = time()-$user['expire_time'];
            if($time<3600){
                db('admins')->where('id', $user['id'])->update(['expire_time' => time()]);
                $user_id = explode('/',base64_decode($token))['2'];
                return $user_id;
            }else{
                return -1;
            }
        }
        return -1;
    }

}
