From 94af65fc5ae540811ce946164a088583d58c32b2 Mon Sep 17 00:00:00 2001 From: Bryan Nielsen Date: Thu, 17 Oct 2024 10:44:13 -0400 Subject: [PATCH] Fix bad query during Relationship Live Preview --- CHANGELOG.md | 4 ++++ src/Fieldtypes/Presenters/Traits/QueriesRelationships.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) 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')