diff --git a/src/Core/Actions/ScheduledActionScanner.php b/src/Core/Actions/ScheduledActionScanner.php index 55a521d..710774c 100644 --- a/src/Core/Actions/ScheduledActionScanner.php +++ b/src/Core/Actions/ScheduledActionScanner.php @@ -60,7 +60,13 @@ class ScheduledActionScanner continue; } - $class = $this->classFromFile($file->getPathname()); + $contents = file_get_contents($file->getPathname()); + + if ($contents === false || ! str_contains($contents, '#[Scheduled')) { + continue; + } + + $class = $this->classFromFile($file->getPathname(), $contents); if ($class === null) { continue; @@ -110,9 +116,9 @@ class ScheduledActionScanner * * Reads the file's namespace declaration and class name. */ - private function classFromFile(string $file): ?string + private function classFromFile(string $file, ?string $contents = null): ?string { - $contents = file_get_contents($file); + $contents ??= file_get_contents($file); if ($contents === false) { return null; diff --git a/src/Core/Activity/Models/Activity.php b/src/Core/Activity/Models/Activity.php index b95a408..52a127e 100644 --- a/src/Core/Activity/Models/Activity.php +++ b/src/Core/Activity/Models/Activity.php @@ -81,9 +81,9 @@ class Activity extends SpatieActivity /** * Get the changed attributes. * - * @return array + * @return \Illuminate\Support\Collection */ - public function getChangesAttribute(): array + public function getChangesAttribute(): \Illuminate\Support\Collection { $old = $this->old_values; $new = $this->new_values; @@ -99,7 +99,7 @@ class Activity extends SpatieActivity } } - return $changes; + return collect($changes); } /** @@ -117,7 +117,7 @@ class Activity extends SpatieActivity { $changes = $this->changes; - if (empty($changes)) { + if ($changes->isEmpty()) { return 'No changes recorded'; }