> ## Documentation Index
> Fetch the complete documentation index at: https://docs.younegotiate.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Soft Delete and Cleanup

> A company reaches the point where inactive records should be soft-deleted or cleaned up.

## Real-World Example

A company reaches the point where inactive records should be soft-deleted or cleaned up. The platform cleanup job should apply only the intended rules and avoid removing records that still matter for billing, reporting, or consumer history.

## Visual Flow

```mermaid placement="top-right" actions={true} theme={"system"}
flowchart TD
    A["Cleanup schedule runs"] --> B["Command finds eligible records"]
    B --> C{"Record safe to clean up?"}
    C -->|Yes| D["Record is soft-deleted or pruned"]
    C -->|No| E["Record is kept"]
    D --> F["Operational data remains consistent"]
    classDef default fill:#F8FAFC,stroke:#64748B,stroke-width:1.5px,color:#0F172A;
    classDef actor fill:#E0F2FE,stroke:#0284C7,stroke-width:2px,color:#0C4A6E;
    classDef system fill:#F8FAFC,stroke:#64748B,stroke-width:1.5px,color:#0F172A;
    classDef decision fill:#FEF3C7,stroke:#D97706,stroke-width:2px,color:#78350F;
    classDef risk fill:#FEE2E2,stroke:#DC2626,stroke-width:2px,color:#7F1D1D;
    classDef outcome fill:#DCFCE7,stroke:#16A34A,stroke-width:2px,color:#14532D;
    class A,B,D,E,F system;
    class C decision;
    class D outcome;
    class E risk;
    linkStyle default stroke:#94A3B8,stroke-width:2px;
```

## How It Should Work

* It should apply cleanup only to records that meet the intended criteria.
* It should preserve history needed for billing, reporting, legal, or consumer account support.
* It should keep soft-deleted records accessible where Super Admin routes intentionally include them.

## How It Should Not Work

* It should not permanently delete important business history without a reviewed rule.
* It should not remove active creditors, active consumers, or records still needed by scheduled jobs.
* It should not make support pages fail when viewing soft-deleted records intentionally.

## Developer Notes

* Soft deletion and pruning are platform safety areas, not normal user-facing workflows.
* Review retention, reporting, and support requirements before changing cleanup criteria.

## Related App Areas

* `app/Console/Commands/SoftDeleteCompaniesCommand.php`
* `Illuminate\Database\Console\PruneCommand`
* `Laravel\Telescope\Console\PruneCommand`
* `routes/superadmin.php`
