diff --git a/packages/framework/src/Console/Helpers/InteractivePublishCommandHelper.php b/packages/framework/src/Console/Helpers/InteractivePublishCommandHelper.php index 2383a3f1be0..496b269e2b6 100644 --- a/packages/framework/src/Console/Helpers/InteractivePublishCommandHelper.php +++ b/packages/framework/src/Console/Helpers/InteractivePublishCommandHelper.php @@ -25,8 +25,6 @@ class InteractivePublishCommandHelper protected readonly string $source; protected readonly string $target; - protected readonly Collection $publishableFilesMap; - public function __construct(string $group) { $this->group = $group; @@ -34,11 +32,11 @@ public function __construct(string $group) public function handle(): string { - $this->publishableFilesMap = $this->mapPublishableFiles($this->findAllFilesForTag()); + $publishableFilesMap = $this->mapPublishableFiles($this->findAllFilesForTag()); - $choices = $this->getFileChoices(); + $choices = $this->getFileChoices($publishableFilesMap); $selectedFiles = multiselect('Select the files you want to publish (CTRL+A to toggle all)', $choices, [], 10, 'required', hint: 'Navigate with arrow keys, space to select, enter to confirm.'); - $filesToPublish = $this->publishableFilesMap->filter(fn (string $file): bool => in_array($file, $selectedFiles)); + $filesToPublish = $publishableFilesMap->filter(fn (string $file): bool => in_array($file, $selectedFiles)); $this->publishFiles($filesToPublish); @@ -77,9 +75,9 @@ protected function getPublishedFilesForOutput(Collection $selectedFiles): string return collect($selectedFiles)->map(fn (string $file): string => Str::after($file, basename($this->source).'/'))->implode(', '); } - public function getFileChoices(): Collection + public function getFileChoices(Collection $publishableFilesMap): Collection { - return $this->publishableFilesMap->mapWithKeys(/** @return array */ function (string $source): array { + return $publishableFilesMap->mapWithKeys(/** @return array */ function (string $source): array { return [$source => Str::after($source, basename($this->target) . '/')]; }); }