Skip to content

Commit 90795e2

Browse files
authored
Merge pull request #221 from pxlrbt/Mahi-Mahi/main
Handle $table->relationship()
2 parents 2c67b53 + 7927660 commit 90795e2

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/Exports/ExcelExport.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,14 @@ public function getModelClass(): ?string
189189
return $this->model;
190190
}
191191

192-
if (($resource = $this->getResourceClass()) !== null) {
192+
$table = $this->getLivewire()->getTable();
193+
194+
if (($relationship = $table->getRelationship()) !== null) {
195+
$model = get_class($relationship->getRelated());
196+
} elseif (($resource = $this->getResourceClass()) !== null) {
193197
$model = $resource::getModel();
194-
} elseif (($livewire = $this->getLivewire()) instanceof HasTable) {
195-
$model = $livewire->getTable()->getModel();
198+
} else {
199+
$model = $table->getModel();
196200
}
197201

198202
return $this->model ??= $model;

0 commit comments

Comments
 (0)