We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1d469c4 commit c3525f2Copy full SHA for c3525f2
src/Http/Api/Contracts/HasParser.php
@@ -79,13 +79,11 @@ protected function filterByParent(): array
79
$this->authorize('view', $routeRelation);
80
}
81
82
- if ($this->request->isMethod('get') || $this->request->isMethod('options')) {
83
- return [
84
- 'filter' => [
85
- $child->{$key}()->getForeignKeyName() => $routeRelation->getKey()
86
- ]
87
- ];
88
- }
+ $filter = match (class_basename(get_class($child->{$key}()))) {
+ 'HasOne' => $child->{$key}()->getLocalKeyName(),
+ 'BelongsToMany' => $key . '.' . $child->{$key}()->getRelatedKeyName(),
+ default => $child->{$key}()->getForeignKeyName(),
+ };
89
90
if ($this->request->isMethod('post') || $this->request->isMethod('put') || $this->request->isMethod('patch')) {
91
return [
0 commit comments