hasOne(OauthSession::class, ['id' => 'session_id']); } public function getScopes() { return new Set(static::getDb()->getSchema()->getRawTableName(static::tableName()), $this->access_token, 'scopes'); } public function beforeDelete() { if (!$result = parent::beforeDelete()) { return $result; } $this->getScopes()->delete(); return true; } public function isExpired() : bool { return time() > $this->expire_time; } }