From 415e15acf778207b29853449a89a801413b44337 Mon Sep 17 00:00:00 2001 From: Arunas Skirius Date: Fri, 17 Oct 2025 09:30:55 +0300 Subject: [PATCH 1/2] Fix LogFileCollection sorting to use idiomatic Laravel .all() method Replace .toArray() with .all() in sortByEarliestFirst() and sortByLatestFirst() to preserve Collection type consistency and maintain idiomatic Laravel patterns. --- src/LogFileCollection.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/LogFileCollection.php b/src/LogFileCollection.php index d2b9621b..6e089519 100644 --- a/src/LogFileCollection.php +++ b/src/LogFileCollection.php @@ -14,7 +14,7 @@ public function sortByEarliestFirst(): self { $this->items = $this->sortBy(function (LogFile $file) { return $file->earliestTimestamp().($file->name ?? ''); - }, SORT_NATURAL)->values()->toArray(); + }, SORT_NATURAL)->values()->all(); return $this; } @@ -23,7 +23,7 @@ public function sortByLatestFirst(): self { $this->items = $this->sortByDesc(function (LogFile $file) { return $file->latestTimestamp().($file->name ?? ''); - }, SORT_NATURAL)->values()->toArray(); + }, SORT_NATURAL)->values()->all(); return $this; } From d36c8998987ce1b4891802c341a4a22342e3c1b5 Mon Sep 17 00:00:00 2001 From: Arunas Skirius Date: Fri, 17 Oct 2025 09:43:04 +0300 Subject: [PATCH 2/2] 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. --- src/LogFileCollection.php | 4 ++-- src/LogFolderCollection.php | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/LogFileCollection.php b/src/LogFileCollection.php index 6e089519..23a44ec5 100644 --- a/src/LogFileCollection.php +++ b/src/LogFileCollection.php @@ -30,14 +30,14 @@ public function sortByLatestFirst(): self public function sortAlphabeticallyAsc(): self { - $this->items = $this->sortBy('name')->values()->toArray(); + $this->items = $this->sortBy('name')->values()->all(); return $this; } public function sortAlphabeticallyDesc(): self { - $this->items = $this->sortByDesc('name')->values()->toArray(); + $this->items = $this->sortByDesc('name')->values()->all(); return $this; } diff --git a/src/LogFolderCollection.php b/src/LogFolderCollection.php index 7fdf0474..394f5038 100644 --- a/src/LogFolderCollection.php +++ b/src/LogFolderCollection.php @@ -18,14 +18,14 @@ public static function fromFiles($files = []): LogFolderCollection public function sortByEarliestFirst(): self { - $this->items = $this->sortBy->earliestTimestamp()->values()->toArray(); + $this->items = $this->sortBy->earliestTimestamp()->values()->all(); return $this; } public function sortByLatestFirst(): self { - $this->items = $this->sortByDesc->latestTimestamp()->values()->toArray(); + $this->items = $this->sortByDesc->latestTimestamp()->values()->all(); return $this; } @@ -60,7 +60,7 @@ public function sortAlphabeticallyAsc(): self return strcmp($a->cleanPath(), $b->cleanPath()); }) ->values() - ->toArray(); + ->all(); return $this; } @@ -79,7 +79,7 @@ public function sortAlphabeticallyDesc(): self return strcmp($b->cleanPath(), $a->cleanPath()); }) ->values() - ->toArray(); + ->all(); return $this; }