Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Health Laravel Package

spatie/laravel-health

Monitor your Laravel app’s health by registering checks (disk space, etc.) with warning/fail thresholds. Get notified via mail or Slack when checks degrade, and extend with custom checks for proactive alerting.

View on GitHub
Deep Wiki
Context7

title: In the database weight: 3

When using the Spatie\Health\ResultStores\EloquentHealthResultStore result store the latest check results will be written to the database. The advantage of stores results in the database, is that you can build up the history of your results. The downside is that, if your database is down, no results can be written.

In the health config file, the store can be configured in the health_stores key like this:

return [
    'result_stores' => [
        EloquentHealthResultStore::class,
    ],

The results will be written in the health_check_result_history_items table. All field names should be self-explanatory. Using the App\Spatie\Models\HealthCheckResultHistoryItem model, you can easily query all results.

Using a custom model

If you'd like to use a custom model for storing health check results, extend the Spatie\Health\Models\HealthCheckResultHistoryItem class, and add it to the EloquentHealthResultStore configuration:

return [
    'result_stores' => [
        Spatie\Health\ResultStores\EloquentHealthResultStore::class => [
            'model' => App\Models\CustomHealthCheckResultModel::class,
        ],
    ],

Pruning the results table

The model uses the Laravel's MassPrunable trait. In the health config file, you can specify the maximum age of a model in the keep_history_for_days key. Don't forget to schedule the model:prune command, as instructed in Laravel's docs. You'll have to explicitly add the model class when it is not in your App\ namespace:

// in routes/console.php
use Illuminate\Support\Facades\Schedule;

Schedule::command('model:prune', ['--model' => [\Spatie\Health\Models\HealthCheckResultHistoryItem::class]])->daily();
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport