From 89a01e5036d877186284d3499dc11ca9e1ecb76d Mon Sep 17 00:00:00 2001 From: Zach Garwood Date: Thu, 30 Jan 2025 14:49:43 -0600 Subject: [PATCH] Patch to address Twill bug in Relation column [WEB-2982] See https://github.com/area17/twill/pull/2720 --- composer.json | 8 +++++-- composer.lock | 10 ++++++--- patches/WEB-2982---fix-relation-column.diff | 24 +++++++++++++++++++++ 3 files changed, 37 insertions(+), 5 deletions(-) create mode 100644 patches/WEB-2982---fix-relation-column.diff diff --git a/composer.json b/composer.json index 7f25f450f..65ab906f8 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "package": { "type": "metapackage", "name": "vendor/package-patches", - "version": "1.5.0", + "version": "1.6.0", "require": { "netresearch/composer-patches-plugin": "~1.2" }, @@ -27,12 +27,16 @@ "patches": { "area17/twill": [ { - "title": "WEB-2103: Get repository model of API models", + "title": "WEB-2301: Get repository model of API models", "url": "patches/WEB-2301---get-repository-of-API-models.diff" }, { "title": "WEB-2678: Backport Node 10 syntax", "url": "patches/WEB-2678---backport-node-10-syntax.diff" + }, + { + "title": "WEB-2982: Fix Relation column", + "url": "patches/WEB-2982---fix-relation-column.diff" } ] } diff --git a/composer.lock b/composer.lock index efd9bcf37..4081f4cdd 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "4405d5c8b38d4bce2720e98ae3665a7d", + "content-hash": "59c5416166ef010ac32ef17f19b0ec4d", "packages": [ { "name": "aic/data-hub-foundation", @@ -10996,7 +10996,7 @@ }, { "name": "vendor/package-patches", - "version": "1.5.0", + "version": "1.6.0", "require": { "netresearch/composer-patches-plugin": "~1.2" }, @@ -11005,12 +11005,16 @@ "patches": { "area17/twill": [ { - "title": "WEB-2103: Get repository model of API models", + "title": "WEB-2301: Get repository model of API models", "url": "patches/WEB-2301---get-repository-of-API-models.diff" }, { "title": "WEB-2678: Backport Node 10 syntax", "url": "patches/WEB-2678---backport-node-10-syntax.diff" + }, + { + "title": "WEB-2982: Fix Relation column", + "url": "patches/WEB-2982---fix-relation-column.diff" } ] } diff --git a/patches/WEB-2982---fix-relation-column.diff b/patches/WEB-2982---fix-relation-column.diff new file mode 100644 index 000000000..d9c4680e6 --- /dev/null +++ b/patches/WEB-2982---fix-relation-column.diff @@ -0,0 +1,24 @@ +diff --git a/src/Services/Listings/Columns/Relation.php b/src/Services/Listings/Columns/Relation.php +index 9c6c05ec..6aa2fdd2 100644 +--- a/src/Services/Listings/Columns/Relation.php ++++ b/src/Services/Listings/Columns/Relation.php +@@ -5,6 +5,7 @@ namespace A17\Twill\Services\Listings\Columns; + use A17\Twill\Exceptions\ColumnMissingPropertyException; + use A17\Twill\Models\Contracts\TwillModelContract; + use A17\Twill\Services\Listings\TableColumn; ++use Illuminate\Support\Collection; + use Illuminate\Support\Str; + + class Relation extends TableColumn +@@ -44,9 +45,9 @@ class Relation extends TableColumn + throw new ColumnMissingPropertyException('Relation column missing relation value: ' . $this->field); + } + +- /** @var \Illuminate\Database\Eloquent\Collection $relation */ + $model->loadMissing($this->relation); +- $relation = collect($model->getRelation($this->relation)); ++ /** @var \Illuminate\Database\Eloquent\Collection $relation */ ++ $relation = Collection::wrap($model->getRelation($this->relation)); + + return $relation->pluck($this->field)->join(', '); + }