Skip to content
Data Health logo

Find and resolve unhealthy data in Laravel

Define application-specific data checks in PHP. Data Health records every occurrence, tracks its status, and helps your team verify or resolve it.

Database constraints and validation keep individual writes valid. They cannot always detect problems that emerge across records or over time: duplicate customers, orders stuck in an impossible state, missing relationships, or stale derived values.

Data Health lets you express these application-specific rules as finding classes. Your application supplies the checks and corrections; Data Health records, deduplicates, and tracks each occurrence as a persistent finding record that your team can review, verify, and resolve.

Finding classes live in configured directories such as app/DataHealth. Data Health discovers them automatically, so each class can focus on the problem it represents instead of registration boilerplate.

Each finding class can support detection, verification, and resolution. Detection searches for problems across your data; verification and resolution act on one recorded occurrence at a time.

Operation What it does
detect() Search candidates and report each occurrence with found().
verify() Recheck one occurrence without changing business data.
resolve() Recheck one occurrence and apply a known application correction.

A true result from verification or resolution marks the finding record resolved. See the contract reference for method signatures and other supported return values.

Add resolution when you have a safe, deterministic correction. Implementing it makes a resolution action available; automatic resolution requires a separate opt-in.

For example, this finding detects orders that have been paid but are still marked as pending:

use App\Models\Order;
use DataHealth\Contracts\CanDetect;
use DataHealth\Finding;
class PaidOrderMarkedPending extends Finding implements CanDetect
{
public static function detect(): null
{
Order::query()
->whereNotNull('paid_at')
->where('status', 'pending')
->get()
->each(function (Order $order): void {
self::found($order);
});
return null;
}
}

Run the detector from Artisan:

Terminal window
php artisan health:detect PaidOrderMarkedPending -n

Omit the finding key to run all discovered detectable findings with -n, or add --async to queue detection. Without -n, terminal sessions open a finding selector. See the CLI Overview for all entrypoints and Detection for command options.

You can also run the detector from application code, a scheduled task, or the optional Filament interface:

PaidOrderMarkedPending::detect();
// null

This run creates or refreshes a persistent finding record for each matching order and returns null. Data Health can present those records for review and track them until the problems are resolved.

The Quick Start extends this example with verification and resolution.

Each finding class can opt into only the capabilities it needs:

  • Detection finds affected models and records the problem.
  • Verification checks whether a previously recorded problem still exists.
  • Resolution performs an application-specific correction.
  • Scheduling runs detection from Laravel’s scheduler using a cron expression.
  • Asynchronous execution queues manual and scheduled detection with Async on the detect() method.
  • Automatic resolution attempts to resolve a finding as soon as it is first recorded.

Attributes can also give a finding a stable key, human-readable descriptions, an urgency, and a worklist. These values make findings easier to organize and present without coupling the core package to a particular user interface.

The Data Health core package owns finding discovery, persistence, lifecycle operations, scheduling, and model integration. It can be used by itself from application code, jobs, commands, APIs, or any interface you build.

The optional data-health-filament package adds a Filament 5 interface with:

  • searchable and filterable finding records;
  • verify, resolve, ignore, and reopen actions;
  • bulk actions for common workflows;
  • a catalogue of registered finding types with manual detection actions;
  • overview statistics for the current state of your data; and
  • standalone Livewire tables that can be embedded outside a Filament panel.

Data Health’s Filament panel showing active findings with urgency, affected models, worklists, and actions to assign, verify, resolve, or ignore each problem.

Both packages use the same finding classes and records, so adding the Filament interface does not change how detection or resolution logic is written.

Follow the Quick Start to build a complete finding workflow, or begin with Installation to add Data Health to a Laravel application.

If you use a coding agent, load the bundled guidance before scanning or generating findings.