Skip to content

Commit

Permalink
fix column-sortable not working with withCount() Kyslik#49
Browse files Browse the repository at this point in the history
  • Loading branch information
ster authored Aug 24, 2023
1 parent 80a7f05 commit c33286f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/ColumnSortable/Sortable.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit c33286f

Please sign in to comment.