Skip to content

Commit d90bfae

Browse files
authored
Merge pull request #2590 from yajra/patch1
Add method exists check taken from #2587.
2 parents c3b9bed + 0528150 commit d90bfae

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/EloquentDataTable.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,8 @@ protected function isMorphRelation($relation)
134134
if ($relation !== null && $relation !== '') {
135135
$relationParts = explode('.', $relation);
136136
$firstRelation = array_shift($relationParts);
137-
$isMorph = $this->query->getModel()->$firstRelation() instanceof MorphTo;
137+
$model = $this->query->getModel();
138+
$isMorph = method_exists($model, $firstRelation) && $model->$firstRelation() instanceof MorphTo;
138139
}
139140

140141
return $isMorph;

0 commit comments

Comments
 (0)