diff --git a/CHANGELOG.md b/CHANGELOG.md index 859fe4a..6ccdef6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## [Unreleased] +### Fixed + +- Incorrect column name used in a Relationship fieldtype query during a Live Preview request + ## [1.4.2] - 2024-09-26 ### Fixed diff --git a/src/Fieldtypes/Presenters/Traits/QueriesRelationships.php b/src/Fieldtypes/Presenters/Traits/QueriesRelationships.php index e2f1ae2..8069935 100644 --- a/src/Fieldtypes/Presenters/Traits/QueriesRelationships.php +++ b/src/Fieldtypes/Presenters/Traits/QueriesRelationships.php @@ -18,7 +18,7 @@ public function buildRelationshipQuery(FieldContent $content, Model $model, $tab $tableName = $tableName ?: Str::singular($model->getTable()).'_relationships'; if ($content->entry->isPreview()) { - $query->whereIn('member_id', $content->data['data'] ?? [0]); + $query->whereIn($model->getKeyName(), $content->data['data'] ?? [0]); } else { $query->select("{$model->getTable()}.*") ->join($tableName, $model->getKeyName(), '=', 'child_id')