<?php

namespace App\Models;

use Illuminate\Auth\GenericUser;
use Tymon\JWTAuth\Contracts\JWTSubject;

/**
 * 授权用户
 */
class User extends GenericUser implements JWTSubject,\ArrayAccess
{
    public function getJWTIdentifier()
    {
        $name = $this->getAuthIdentifierName();

        return $this->attributes[$name];
    }

    /**
     * token的附加属性
     * @return array
     */
    public function getJWTCustomClaims()
    {
        return [
            'api_token'=>$this->attributes['api_token']
        ];
    }

    public function offsetExists($offset)
    {
        return isset($this->attributes[$offset]);
    }

    public function offsetGet($offset)
    {
        return $this->attributes[$offset];
    }

    public function offsetSet($offset, $value)
    {
        return $this->attributes[$offset] = $value;
    }

    public function offsetUnset($offset)
    {
        unset($this->attributes[$offset]);
    }
}
