diff --git a/src/ColumnSortable/Sortable.php b/src/ColumnSortable/Sortable.php index c4fcebb..a7b6540 100755 --- a/src/ColumnSortable/Sortable.php +++ b/src/ColumnSortable/Sortable.php @@ -219,6 +219,10 @@ private function formJoin($query, $parentTable, $relatedTable, $parentPrimaryKey { $joinType = config('columnsortable.join_type', 'leftJoin'); - return $query->select($parentTable.'.*')->{$joinType}($relatedTable, $parentPrimaryKey, '=', $relatedPrimaryKey); + if ($query->getQuery()->columns === null) { + $query->select($parentTable.'.*'); + } + + return $query->{$joinType}($relatedTable, $parentPrimaryKey, '=', $relatedPrimaryKey); } }