Skip to content

Commit 27e6990

Browse files
committed
Fixed formatting for relational column - #757
1 parent 518e474 commit 27e6990

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ All notable changes to `laravel-livewire-tables` will be documented in this file
44

55
## [Unreleased]
66

7+
## [2.9.0] - 2022-12-XX
8+
9+
### Added
10+
11+
### Changed
12+
13+
- Fixed formatting for relational column - https://github.com/rappasoft/laravel-livewire-tables/pull/757
14+
715
## [2.8.0] - 2022-07-24
816

917
### Added

src/Traits/WithSorting.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@ public function applySorting(): Builder
8080
} elseif ($column->isBaseColumn()) {
8181
$this->setBuilder($this->getBuilder()->orderBy($column->getColumnSelectName(), $direction));
8282
} else {
83-
$this->setBuilder($this->getBuilder()->orderByRaw('"'.$column->getColumnSelectName().'"' . ' ' . $direction));
83+
$value = $this->getBuilder()->getGrammar()->wrap($column->getColumn() . ' as ' . $column->getColumnSelectName());
84+
$segments = preg_split('/\s+as\s+/i', $value);
85+
$this->setBuilder($this->getBuilder()->orderByRaw($segments[1] . ' ' . $direction));
8486
}
8587
}
8688

0 commit comments

Comments
 (0)