hasMany(OauthAccessToken::class, ['session_id' => 'id']); } public function getClient() { return $this->hasOne(OauthClient::class, ['id' => 'client_id']); } public function getAccount() { return $this->hasOne(Account::class, ['id' => 'owner_id']); } public function getScopes() { return new Set($this->getDb()->getSchema()->getRawTableName($this->tableName()), $this->id, 'scopes'); } public function beforeDelete() { if (!$result = parent::beforeDelete()) { return $result; } $this->getScopes()->delete(); return true; } }