PHPackages                             myparcelcom/resource-cleanup - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. myparcelcom/resource-cleanup

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

myparcelcom/resource-cleanup
============================

Clean up soft-deleted and expired records from your Laravel application after a configurable cutoff date.

0400PHPCI passing

Since May 27Pushed 1mo agoCompare

[ Source](https://github.com/MyParcelCOM/resource-cleanup)[ Packagist](https://packagist.org/packages/myparcelcom/resource-cleanup)[ RSS](/packages/myparcelcom-resource-cleanup/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependenciesVersions (2)Used By (0)

resource-cleanup
================

[](#resource-cleanup)

[![Tests](https://github.com/myparcelcom/resource-cleanup/actions/workflows/tests.yml/badge.svg)](https://github.com/myparcelcom/resource-cleanup/actions/workflows/tests.yml)

A Laravel package to permanently delete soft-deleted or expired records based on a defined "cleanable" query scope or after a configurable cutoff date.

Requirements
------------

[](#requirements)

- PHP 8.2+
- Laravel 9, 10, 11, or 12

Installation
------------

[](#installation)

```
composer require myparcelcom/resource-cleanup
```

Update Laravel's package auto-discovery cache

```
php artisan package:discover
```

Publish the config file:

```
php artisan vendor:publish --tag=resource-cleanup-config
```

Configuration
-------------

[](#configuration)

`config/resource-cleanup.php`:

```
return [
    // Records older than this many days will be deleted (default: 90)
    'default_retention_days' => env('RESOURCE_CLEANUP_RETENTION_DAYS', 90),

    // Valid models to clean up
    'models' => [
        \App\Models\Order::class,
        \App\Models\AuditLog::class,
    ],
];
```

Usage
-----

[](#usage)

### Artisan Command

[](#artisan-command)

Run cleanup for all models defined in the config:

```
php artisan resource-cleanup:run
```

Target specific models from the config:

```
php artisan resource-cleanup:run --model=App\\Models\\Order
```

Preview what would be deleted without deleting anything:

```
php artisan resource-cleanup:run --dry-run
```

### Per-Model Cutoff Dates

[](#per-model-cutoff-dates)

Implement the `CleanableResource` contract on any model to define its own retention period:

```
use Illuminate\Database\Eloquent\Builder;
use MyParcelCom\ResourceCleanup\Contracts\CleanableResource;

class AuditLog extends Model implements CleanableResource
{
    public static function scopeCleanable(): Builder
    {
        // narrow down the query scope by adding where() clauses
        return self::query();
    }
}
```

Testing
-------

[](#testing)

### With Docker (recommended)

[](#with-docker-recommended)

Build the container and run the test suite:

```
docker compose run --rm app
```

Run a specific test or filter:

```
docker compose run --rm app vendor/bin/phpunit --filter test_it_deletes_soft_deleted_records
```

Drop into a shell inside the container:

```
docker compose run --rm app bash
```

Run Composer commands without installing PHP locally:

```
docker compose run --rm app composer require some/package
```

### Without Docker

[](#without-docker)

```
composer install
composer test
```

###  Health Score

25

—

LowBetter than 35% of packages

Maintenance58

Moderate activity, may be stable

Popularity18

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity13

Early-stage or recently created project

 Bus Factor1

Top contributor holds 85.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/3841efa190ba5131014f8855131e3d38ef5ccd57c51000966348108e63c83612?d=identicon)[myparcelcom](/maintainers/myparcelcom)

---

Top Contributors

[![yoerriwalstra](https://avatars.githubusercontent.com/u/48599583?v=4)](https://github.com/yoerriwalstra "yoerriwalstra (35 commits)")[![daniel-myparcel](https://avatars.githubusercontent.com/u/193501397?v=4)](https://github.com/daniel-myparcel "daniel-myparcel (4 commits)")[![NickVries](https://avatars.githubusercontent.com/u/32866117?v=4)](https://github.com/NickVries "NickVries (2 commits)")

### Embed Badge

![Health badge](/badges/myparcelcom-resource-cleanup/health.svg)

```
[![Health](https://phpackages.com/badges/myparcelcom-resource-cleanup/health.svg)](https://phpackages.com/packages/myparcelcom-resource-cleanup)
```

###  Alternatives

[intvent/eboekhouden-php

A PHP framework agnostic package for E-boekhouden.nl

1210.3k](/packages/intvent-eboekhouden-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
