PHPackages                             naviisml/laravel-reaper - 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. [Database &amp; ORM](/categories/database)
4. /
5. naviisml/laravel-reaper

ActiveLibrary[Database &amp; ORM](/categories/database)

naviisml/laravel-reaper
=======================

Automatic, rule-based purging of Eloquent models.

1.0.0(5mo ago)056MITPHP

Since Jan 21Pushed 5mo agoCompare

[ Source](https://github.com/naviisml/laravel-reaper)[ Packagist](https://packagist.org/packages/naviisml/laravel-reaper)[ RSS](/packages/naviisml-laravel-reaper/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (4)Versions (2)Used By (0)

🪦 Reaper
========

[](#-reaper)

**Automatic, rule-based purging of Eloquent models.**

Reaper is a Laravel package that safely and declaratively **force-deletes soft-deleted models** after configurable grace periods — with support for:

- ⏱ Simple retention periods (`30d`)
- 🧩 Composite periods (`3w10d1h`)
- 🔗 Multiple conditions (`last_activity + deleted_at`)
- 🔀 AND / OR logic
- 🧠 Custom purge conditions
- ⏰ Scheduler-driven + manual execution

Features
--------

[](#features)

- One global scheduler — no per-model cron jobs
- Declarative purge rules on models — custom condition evaluation logic
- Custom purge conditions (closures or classes)
- Chunked &amp; queue-safe

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

[](#installation)

```
composer require naviisml/laravel-reaper
```

Laravel will auto-discover the service provider.

🚀 Quick Start
-------------

[](#-quick-start)

```
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Naviisml\Reaper\Concerns\IsReapable;

class User extends Model
{
    use SoftDeletes;
    use IsReapable;

    protected string $period = '30d';
}
```

That’s it.

Reaper will automatically **force-delete users** that have been soft-deleted for more than 30 days.

Supported Period Format
-----------------------

[](#supported-period-format)

Reaper uses a compact, human-readable period syntax:

UnitMeaning`h`hours`d`days`w`weeks`m`months`y`years (optional extension)### Examples

[](#examples)

```
30d
12h
3w10d1h
1y2m

```

Advanced Retention Rules
------------------------

[](#advanced-retention-rules)

> Note: If all the fields match, but the model is not yet soft deleted, the model will first be soft deleted. If the model doesnt support soft deletes, it will be deleted.

### Multiple conditions (AND by default)

[](#multiple-conditions-and-by-default)

```
protected array $periods = [
    'last_activity' => '1y',
    'deleted_at'    => '1m',
];
```

Meaning:

```
last_activity  [
        ['column' => 'deleted_at', 'older_than' => '30d'],
        ['column' => 'last_login', 'older_than' => '1y'],
    ],
];
```

### OR

[](#or)

```
protected array $purge = [
    'or' => [
        ['column' => 'deleted_at', 'older_than' => '6m'],
        ['column' => 'bounced_at', 'older_than' => '7d'],
    ],
];
```

### Nested conditions

[](#nested-conditions)

```
protected array $purge = [
    'and' => [
        ['column' => 'deleted_at', 'older_than' => '30d'],
        [
            'or' => [
                ['column' => 'last_activity', 'older_than' => '1y'],
                ['column' => 'last_login',    'older_than' => '18m'],
            ],
        ],
    ],
];
```

### Closure-based

[](#closure-based)

```
protected array $purge = [
    'and' => [
        fn ($query) => $query->whereNull('subscription_id'),
        ['column' => 'deleted_at', 'older_than' => '14d'],
    ],
];
```

### Class-based

[](#class-based)

```
protected array $purge = [
    'and' => [
        \App\Purge\InactiveTrialCondition::class,
        ['column' => 'deleted_at', 'older_than' => '14d'],
    ],
];
```

```
class InactiveTrialCondition
{
    public function apply($query): void
    {
        $query->where('trial_ended', true);
    }
}
```

Scheduler
---------

[](#scheduler)

Reaper automatically registers a scheduled job:

- Runs **hourly**
- Uses `withoutOverlapping()`
- Chunked deletes (`chunkById`)
- Queue-safe

Make sure Laravel’s scheduler is running:

```
* * * * * php artisan schedule:run
```

Commands
--------

[](#commands)

**Run Purge Manually**

**Dispatch via queue (default)**

```
php artisan reaper:purge
```

**Run synchronously (debug / CI)**

```
php artisan reaper:purge --sync
```

📄 License
---------

[](#-license)

MIT © Naviisml

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance71

Regular maintenance activity

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity35

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

163d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/43450192?v=4)[Navi](/maintainers/naviisml)[@naviisml](https://github.com/naviisml)

---

Top Contributors

[![naviisml](https://avatars.githubusercontent.com/u/43450192?v=4)](https://github.com/naviisml "naviisml (1 commits)")

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/naviisml-laravel-reaper/health.svg)

```
[![Health](https://phpackages.com/badges/naviisml-laravel-reaper/health.svg)](https://phpackages.com/packages/naviisml-laravel-reaper)
```

###  Alternatives

[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k117.2M118](/packages/jdorn-sql-formatter)[propel/propel1

Propel is an open-source Object-Relational Mapping (ORM) for PHP5.

8351.6M87](/packages/propel-propel1)[pgvector/pgvector

pgvector support for PHP

198741.5k12](/packages/pgvector-pgvector)[jfelder/oracledb

Oracle DB driver for Laravel

11518.4k](/packages/jfelder-oracledb)

PHPackages © 2026

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