diff --git a/docs/basic-usage/creating-custom-checks.md b/docs/basic-usage/creating-custom-checks.md index d3ee93e7..efa20bf2 100644 --- a/docs/basic-usage/creating-custom-checks.md +++ b/docs/basic-usage/creating-custom-checks.md @@ -135,3 +135,7 @@ class UsedDiskSpaceCheck extends Check } ``` +## Adding a label + + + diff --git a/docs/viewing-results/_index.md b/docs/viewing-results/_index.md new file mode 100644 index 00000000..9b895e0f --- /dev/null +++ b/docs/viewing-results/_index.md @@ -0,0 +1,4 @@ +--- +title: Viewing check results +weight: 3 +--- diff --git a/docs/viewing-results/as-json-via-an-api.md b/docs/viewing-results/as-json-via-an-api.md new file mode 100644 index 00000000..be857496 --- /dev/null +++ b/docs/viewing-results/as-json-via-an-api.md @@ -0,0 +1,4 @@ +--- +title: As JSON via an API +weight: 3 +--- diff --git a/docs/viewing-results/on-a-webpage.md b/docs/viewing-results/on-a-webpage.md new file mode 100644 index 00000000..26549a2a --- /dev/null +++ b/docs/viewing-results/on-a-webpage.md @@ -0,0 +1,4 @@ +--- +title: On a webpage +weight: 1 +--- diff --git a/docs/viewing-results/on-the-cli.md b/docs/viewing-results/on-the-cli.md new file mode 100644 index 00000000..846bd3dd --- /dev/null +++ b/docs/viewing-results/on-the-cli.md @@ -0,0 +1,4 @@ +--- +title: On the CLI +weight: 2 +--- diff --git a/resources/views/cli/list.blade.php b/resources/views/cli/list.blade.php index 91b9c240..d061d2bc 100644 --- a/resources/views/cli/list.blade.php +++ b/resources/views/cli/list.blade.php @@ -1,9 +1,9 @@ -
+
@if(count($checkResults->storedCheckResults)) -
Check results
+
Check results
-
- Last ran all the checks {{ $lastRanAt->diffForHumans() }} +
+ Last ran all the checks {{ $lastRanAt->diffForHumans() }}.
@@ -24,11 +24,12 @@ @endforeach
- @else +
No checks have run yet...
Please execute: php artisan health:run-checks +
@endif
diff --git a/src/Checks/Result.php b/src/Checks/Result.php index e1c22b56..7290ac8d 100644 --- a/src/Checks/Result.php +++ b/src/Checks/Result.php @@ -3,6 +3,7 @@ namespace Spatie\Health\Checks; use Carbon\Carbon; +use Illuminate\Support\Str; use Spatie\Health\Enums\Status; use function trans; @@ -32,6 +33,15 @@ public function shortSummary(string $shortSummary): self return $this; } + public function getShortSummary(): string + { + if (! empty($this->shortSummary)) { + return $this->shortSummary; + } + + return Str::of($this->status)->snake()->replace('_', ' ')->title(); + } + public function check(Check $check): self { $this->check = $check; diff --git a/src/Commands/RunChecksCommand.php b/src/Commands/RunChecksCommand.php index c4768d1b..f6730d3b 100644 --- a/src/Commands/RunChecksCommand.php +++ b/src/Commands/RunChecksCommand.php @@ -56,7 +56,7 @@ public function runCheck(Check $check): Result event(new CheckStartingEvent($check)); try { - $this->comment("Running check: {$check->getName()}"); + $this->comment("Running check: {$check->getLabel()}"); $result = $check->run(); } catch (Exception $exception) { $exception = CheckDidNotComplete::make($check, $exception); diff --git a/src/ResultStores/EloquentHealthResultStore.php b/src/ResultStores/EloquentHealthResultStore.php index d2b3b965..1f459854 100644 --- a/src/ResultStores/EloquentHealthResultStore.php +++ b/src/ResultStores/EloquentHealthResultStore.php @@ -22,7 +22,7 @@ public function save(Collection $checkResults): void 'check_label' => $result->check->getLabel(), 'status' => $result->status, 'notification_message' => $result->getNotificationMessage(), - 'short_summary' => $result->shortSummary, + 'short_summary' => $result->getShortSummary(), 'meta' => $result->meta, 'batch' => $batch, 'ended_at' => $result->ended_at, diff --git a/src/ResultStores/JsonFileHealthResultStore.php b/src/ResultStores/JsonFileHealthResultStore.php index a742eb3a..779aacee 100644 --- a/src/ResultStores/JsonFileHealthResultStore.php +++ b/src/ResultStores/JsonFileHealthResultStore.php @@ -33,7 +33,7 @@ public function save(Collection $checkResults): void name: $result->check->getName(), label: $result->check->getLabel(), notificationMessage: $result->getNotificationMessage(), - shortSummary: $result->shortSummary, + shortSummary: $result->getShortSummary(), status: (string)$result->status->value, meta: $result->meta, );