public function getByApiToken(int $id, string $token) : ?Authenticatable
    {
        $model = $this->getModel();

        $user = $model->newQuery()
                      ->where($model->getAuthIdentifierName(), $id)
                      ->first();

        if ($user === null) {
            return null;
        }

        $apiToken = $user->getApiToken();

        return !empty($apiToken) && hash_equals($apiToken, $token) ? $user : null;
    }
public function getByApiToken(int $id, string $token) : ?Authenticatable
    {
        $model = $this->getModel();

        $user = $model->newQuery()
                      ->where($model->getAuthIdentifierName(), $id)
                      ->first();

        if ($user === null) {
            return null;
        }

        $apiToken = $user->getApiToken();

        return !empty($apiToken) && hash_equals($apiToken, $token) ? $user : null;
    }
public function getByApiToken ( int $ id , string $ token ) : ? Authenticatable { $ model = $ this -> getModel ( ) ; $ user = $ model -> newQuery ( ) -> where ( $ model -> getAuthIdentifierName ( ) , $ id ) -> first ( ) ; if ( $ user === null ) { return null ; } $ apiToken = $ user -> getApiToken ( ) ; return ! empty ( $ apiToken ) && hash_equals ( $ apiToken , $ token ) ? $ user : null ; }
Retrieve a user by their unique identifier and api token.

@param  int  $id
@param  string $token
@return \Illuminate\Contracts\Auth\Authenticatable|\Illuminate\Database\Eloquent\Builder|User|null
Retrieve a user by their unique identifier and api token .