Get key name from adapter model, not query model

This commit is contained in:
Toby Zerner 2022-06-21 14:53:30 +09:30
parent 2ca836d7ef
commit 7cab9545b4
No known key found for this signature in database
GPG Key ID: 9F2272AAFC4824D9
2 changed files with 7 additions and 1 deletions

View File

@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [0.2.0] - 2022-06-21
### Fixed
- Fix `EloquentAdapter::filterByIds()` getting key name from query model instead of adapter model
## [0.2.0-beta.6] - 2022-04-22
### Changed
- Add support for `doctrine/inflector:^2.0`
@ -74,6 +78,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- Fix pagination next link appearing when it shouldn't
[0.2.0]: https://github.com/tobyzerner/json-api-server/compare/v0.2.0...v0.2.0-beta.6
[0.2.0-beta.6]: https://github.com/tobyzerner/json-api-server/compare/v0.2.0-beta.6...v0.2.0-beta.5
[0.2.0-beta.5]: https://github.com/tobyzerner/json-api-server/compare/v0.2.0-beta.5...v0.2.0-beta.4
[0.2.0-beta.4]: https://github.com/tobyzerner/json-api-server/compare/v0.2.0-beta.4...v0.2.0-beta.3
[0.2.0-beta.3]: https://github.com/tobyzerner/json-api-server/compare/v0.2.0-beta.3...v0.2.0-beta.2

View File

@ -48,7 +48,7 @@ class EloquentAdapter implements AdapterInterface
public function filterByIds($query, array $ids): void
{
$query->whereIn($query->getModel()->getQualifiedKeyName(), $ids);
$query->whereIn($this->model->getQualifiedKeyName(), $ids);
}
public function filterByAttribute($query, Attribute $attribute, $value, string $operator = '='): void