Skip to content

Commit

Permalink
Patch to address Twill bug in Relation column [WEB-2982]
Browse files Browse the repository at this point in the history
  • Loading branch information
zachgarwood authored and nikhiltri committed Feb 6, 2025
1 parent c48cbaa commit 7b29f85
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 5 deletions.
8 changes: 6 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,24 @@
"package": {
"type": "metapackage",
"name": "vendor/package-patches",
"version": "1.5.0",
"version": "1.6.0",
"require": {
"netresearch/composer-patches-plugin": "~1.2"
},
"extra": {
"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"
}
]
}
Expand Down
10 changes: 7 additions & 3 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions patches/WEB-2982---fix-relation-column.diff
Original file line number Diff line number Diff line change
@@ -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(', ');
}

0 comments on commit 7b29f85

Please sign in to comment.