$deletions */ public function __construct(protected BaseModel $model, protected array $deletions = []) {} public function toLog(): void { if ($this->deletions === []) { Log::error('No deletions were attempted.'); } foreach ($this->deletions as $fs => $result) { $result ? Log::info("Deleted '{$this->model->getName()}' from disk '$fs'") : Log::error("Failed to delete '{$this->model->getName()}' from disk '$fs'"); } } public function toConsole(Command $command): void { if ($this->deletions === []) { $command->error('No deletions were attempted.'); } foreach ($this->deletions as $fs => $result) { $result ? $command->info("Deleted '{$this->model->getName()}' from disk '$fs'") : $command->error("Failed to delete '{$this->model->getName()}' from disk '$fs'"); } } public function toActionResult(): ActionResult { if ($this->deletions === []) { return new ActionResult( ActionStatus::FAILED, 'No deletions were attempted. Please check that disks are configured.' ); } /** @var Collection $passed */ /** @var Collection $failed */ [$passed, $failed] = collect($this->deletions)->partition(fn (bool $result, string $fs): bool => $result); if ($failed->isNotEmpty()) { return new ActionResult( ActionStatus::FAILED, "Failed to delete '{$this->model->getName()}' from disks {$failed->keys()->join(', ', ' & ')}." ); } return new ActionResult( ActionStatus::PASSED, "Deleted '{$this->model->getName()}' from disks {$passed->keys()->join(', ', ' & ')}." ); } }