File tree Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change 44
55trait SortingConfiguration
66{
7+ protected function setupDefaultSorting (): void
8+ {
9+ if ($ this ->sortingIsEnabled () && $ this ->hasDefaultSort () && ! $ this ->hasSorts ()) {
10+ $ this ->setSort ($ this ->getDefaultSortColumn (), $ this ->getDefaultSortDirection ());
11+ }
12+ }
13+
714 public function setSortingStatus (bool $ status ): self
815 {
916 $ this ->sortingStatus = $ status ;
Original file line number Diff line number Diff line change @@ -32,6 +32,11 @@ trait WithSorting
3232
3333 public string $ defaultSortingLabelDesc = 'Z-A ' ;
3434
35+ public function mountWithSorting (): void
36+ {
37+ $ this ->setupDefaultSorting ();
38+ }
39+
3540 public function sortBy (string $ columnSelectName ): ?string
3641 {
3742
@@ -66,11 +71,7 @@ public function sortBy(string $columnSelectName): ?string
6671
6772 public function applySorting (): Builder
6873 {
69- if ($ this ->hasDefaultSort () && ! $ this ->hasSorts ()) {
70- $ this ->setBuilder ($ this ->getBuilder ()->orderBy ($ this ->getDefaultSortColumn (), $ this ->getDefaultSortDirection ()));
7174
72- return $ this ->getBuilder ();
73- }
7475 $ allCols = $ this ->getColumns ();
7576
7677 foreach ($ this ->getSorts () as $ column => $ direction ) {
You can’t perform that action at this time.
0 commit comments