Skip to content

Commit d36c899

Browse files
committed
Use .all() consistently across all collection sorting methods
Update LogFileCollection and LogFolderCollection to use .all() instead of .toArray() in all sorting methods for idiomatic Laravel patterns and Collection type consistency.
1 parent 415e15a commit d36c899

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/LogFileCollection.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ public function sortByLatestFirst(): self
3030

3131
public function sortAlphabeticallyAsc(): self
3232
{
33-
$this->items = $this->sortBy('name')->values()->toArray();
33+
$this->items = $this->sortBy('name')->values()->all();
3434

3535
return $this;
3636
}
3737

3838
public function sortAlphabeticallyDesc(): self
3939
{
40-
$this->items = $this->sortByDesc('name')->values()->toArray();
40+
$this->items = $this->sortByDesc('name')->values()->all();
4141

4242
return $this;
4343
}

src/LogFolderCollection.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ public static function fromFiles($files = []): LogFolderCollection
1818

1919
public function sortByEarliestFirst(): self
2020
{
21-
$this->items = $this->sortBy->earliestTimestamp()->values()->toArray();
21+
$this->items = $this->sortBy->earliestTimestamp()->values()->all();
2222

2323
return $this;
2424
}
2525

2626
public function sortByLatestFirst(): self
2727
{
28-
$this->items = $this->sortByDesc->latestTimestamp()->values()->toArray();
28+
$this->items = $this->sortByDesc->latestTimestamp()->values()->all();
2929

3030
return $this;
3131
}
@@ -60,7 +60,7 @@ public function sortAlphabeticallyAsc(): self
6060
return strcmp($a->cleanPath(), $b->cleanPath());
6161
})
6262
->values()
63-
->toArray();
63+
->all();
6464

6565
return $this;
6666
}
@@ -79,7 +79,7 @@ public function sortAlphabeticallyDesc(): self
7979
return strcmp($b->cleanPath(), $a->cleanPath());
8080
})
8181
->values()
82-
->toArray();
82+
->all();
8383

8484
return $this;
8585
}

0 commit comments

Comments
 (0)