Skip to content

Commit a337555

Browse files
committed
Merge branch 'master' of https://github.com/DanielGSoftware/laravel-livewire-tables into DanielGSoftware-master
2 parents 7281989 + 902f707 commit a337555

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/Traits/WithData.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Illuminate\Database\Eloquent\Builder;
66
use Illuminate\Database\Eloquent\Relations\BelongsTo;
77
use Illuminate\Database\Eloquent\Relations\HasOne;
8+
use Illuminate\Database\Eloquent\Relations\MorphOne;
89
use Rappasoft\LaravelLivewireTables\Views\Column;
910

1011
trait WithData
@@ -77,6 +78,7 @@ protected function joinRelation(Column $column): Builder
7778
$model = $lastQuery->getRelation($relationPart);
7879

7980
switch (true) {
81+
case $model instanceof MorphOne:
8082
case $model instanceof HasOne:
8183
$table = $model->getRelated()->getTable();
8284
$foreign = $model->getQualifiedForeignKeyName();
@@ -139,7 +141,7 @@ protected function getTableForColumn(Column $column): ?string
139141
foreach ($column->getRelations() as $relationPart) {
140142
$model = $lastQuery->getRelation($relationPart);
141143

142-
if ($model instanceof HasOne || $model instanceof BelongsTo) {
144+
if ($model instanceof HasOne || $model instanceof BelongsTo || $model instanceof MorphOne) {
143145
$table = $model->getRelated()->getTable();
144146
}
145147

0 commit comments

Comments
 (0)