PHPackages                             spinen/laravel-garbage-man - 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. spinen/laravel-garbage-man

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

spinen/laravel-garbage-man
==========================

Scheduled job to clean out Laravel's soft deleted records at configured interval.

2.5.0(3y ago)3619.1k↓83.8%2MITPHPPHP &gt;=8.1

Since Oct 12Pushed 3y ago3 watchersCompare

[ Source](https://github.com/spinen/laravel-garbage-man)[ Packagist](https://packagist.org/packages/spinen/laravel-garbage-man)[ RSS](/packages/spinen-laravel-garbage-man/feed)WikiDiscussions develop Synced yesterday

READMEChangelog (2)Dependencies (10)Versions (24)Used By (0)

SPINEN's Laravel Garbage Man
============================

[](#spinens-laravel-garbage-man)

[![Latest Stable Version](https://camo.githubusercontent.com/71764201297edf61cbfb262b24f8a5a794d73efe23a8f2e7952f5a5ceaa41214/68747470733a2f2f706f7365722e707567782e6f72672f7370696e656e2f6c61726176656c2d676172626167652d6d616e2f762f737461626c65)](https://packagist.org/packages/spinen/laravel-garbage-man)[![Latest Unstable Version](https://camo.githubusercontent.com/06131b3306ee6f4ea2c112c571d2a35d62612ccd972b76d6d7c07b032b81f227/68747470733a2f2f706f7365722e707567782e6f72672f7370696e656e2f6c61726176656c2d676172626167652d6d616e2f762f756e737461626c65)](https://packagist.org/packages/spinen/laravel-garbage-man)[![Total Downloads](https://camo.githubusercontent.com/7135f4bbc1cbe67cd8e2dc07f2e25be7f4a54645f07676a417ee7490723ae499/68747470733a2f2f706f7365722e707567782e6f72672f7370696e656e2f6c61726176656c2d676172626167652d6d616e2f646f776e6c6f616473)](https://packagist.org/packages/spinen/laravel-garbage-man)[![License](https://camo.githubusercontent.com/642ac2b680d1d31a7256d03ebc2b8a195a40e6fa9163211fda9bf08c45fc125a/68747470733a2f2f706f7365722e707567782e6f72672f7370696e656e2f6c61726176656c2d676172626167652d6d616e2f6c6963656e7365)](https://packagist.org/packages/spinen/laravel-garbage-man)

The soft deletes are great in Laravel to make sure that some deleted data can be recovered. This package allows you to configure an array of models with how many days that you want the soft deleted data to stay in the database.

Build Status
------------

[](#build-status)

BranchStatusCoverageCode QualityDevelop[![Build Status](https://github.com/spinen/laravel-garbage-man/workflows/CI/badge.svg?branch=develop)](https://github.com/spinen/laravel-garbage-man/workflows/CI/badge.svg?branch=develop)[![Code Coverage](https://camo.githubusercontent.com/a9863f020e25a50125fb0cc331dc3ae3911fc6600ec6c2bc3314742d370fbbed/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7370696e656e2f6c61726176656c2d676172626167652d6d616e2f6261646765732f636f7665726167652e706e673f623d646576656c6f70)](https://scrutinizer-ci.com/g/spinen/laravel-garbage-man/?branch=develop)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/09ea57de47302a1a56b3c4c57d38ab95f8585712e17212e4baf261dde42cfef4/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7370696e656e2f6c61726176656c2d676172626167652d6d616e2f6261646765732f7175616c6974792d73636f72652e706e673f623d646576656c6f70)](https://scrutinizer-ci.com/g/spinen/laravel-garbage-man/?branch=develop)Master[![Build Status](https://github.com/spinen/laravel-garbage-man/workflows/CI/badge.svg?branch=master)](https://github.com/spinen/laravel-garbage-man/workflows/CI/badge.svg?branch=master)[![Code Coverage](https://camo.githubusercontent.com/7ba1d7f57a695ed657b0107860eb1e8963c280fd3ecc97df8026fe3d07a1511e/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7370696e656e2f6c61726176656c2d676172626167652d6d616e2f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/spinen/laravel-garbage-man/?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/9213cb6487cd2bae2ff2ea2d7dc8da9bc7c7bae43cc77bf4486b725844cea4ea/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7370696e656e2f6c61726176656c2d676172626167652d6d616e2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/spinen/laravel-garbage-man/?branch=master)Prerequisite
------------

[](#prerequisite)

#### NOTE: If you need to use &lt; PHP 7.2, please stay with version 1.x

[](#note-if-you-need-to-use--php-72-please-stay-with-version-1x)

As side from Laravel &gt;= 5.1.10 (5.1.10 is the first version that had the warn method, so that is the minimum for logging), there is 1 package that is required.

- [nesbot/carbon](https://github.com/briannesbitt/Carbon)

Install
-------

[](#install)

Install Garbage Man:

```
$ composer require spinen/laravel-garbage-man
```

### For &gt;= Laravel 5.5, you are done with the installation

[](#for--laravel-55-you-are-done-with-the-installation)

The package uses the [auto registration feature](https://laravel.com/docs/5.8/packages#package-discovery) of Laravel 5.

Upgrading to 2.x from 1.x
-------------------------

[](#upgrading-to-2x-from-1x)

As of Laravel 5.8 (and deprecated in 5.4), the `fire()` method on the dispatcher contract [was removed](https://laravel.com/docs/5.8/upgrade) in favor of `dispatch()`. Therefore, we have updated our code to use `dispatch()`. You will need to change `fire()` to `dispatch()` in your `config/garbageman.php` file.

Using the command
-----------------

[](#using-the-command)

The command is registered with laravel as `garbageman:purge`. You can run it one of 2 ways...

1. from the command line `php artisan garbageman:purge;`
2. via a scheduled task.

To automatically run the script as a scheduled job, then add the following to the schedule method of `App\Console\Kernel.php`:

```
$schedule->command('garbageman:purge')
         ->daily();
```

You can use whatever schedule that you need to keep the records purged out. Just review the list at .

You can also use any of the advanced configuration options of the task scheduler like "Task Output" or "Task Hooks" as listed on the [Laravel documentation](http://laravel.com/docs/master/scheduling).

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

[](#configuration)

Publish the package config file to `config/garbageman.php`:

```
$ php artisan vendor:publish
```

This file is fully documented. You will need to make the changes to that file to suit your needs. There are 3 main configuration items...

1. Dispatch purge events - Dispatch events on purge of each record.
2. Logging level - Level to log.
3. Schedule - Models &amp; number of days to allow the soft deleted record to stay before purging.

### Dispatch purge events (dispatch\_purge\_events)

[](#dispatch-purge-events-dispatch_purge_events)

You may hook into the purge of each record by throwing events before &amp; after deleting of each record. There are 2 events thrown:

- garbageman.purging:&lt;full/model/name&gt;
- garbageman.purged:&lt;full/model/name&gt;

The model is passed with each of the events. The "purging" event is thrown just *before* the actual delete &amp; "purged" is thrown just *after* the actual deletion.

**Please note:** This is an expensive operation as it requires a SQL command for each record to delete so that the record can be thrown with the events. Therefore, unless you need to catch the events to perform some other action, leave this false to allow all records per model to get deleted with a single SQL call.

### Logging level (logging\_level)

[](#logging-level-logging_level)

The level that log messages are generated, which will display information on the console output and in the logs.

LevelDescription0Emergency: system is unusable1Alert: action must be taken immediately2Critical: critical conditions3Error: error conditions4Warning: warning conditions5Notice: normal but significant condition6 (default)Info: informational messages7Debug: debug - level messagesThere is a key for the console &amp; one for the log. Here is an example...

```
'logging_level' => [
    'console' => 3,
    'log'     => 6,
],
```

Alternatively, you can set the levels with environmental variables `GARBAGEMAN_CONSOLE_LOG_LEVEL` and `GARBAGEMAN_LOG_LEVEL`.

### Schedule (schedule)

[](#schedule-schedule)

The age is in days for each model. Here is an example...

```
'schedule' => [
    App\ModelOne::class => 14,
    App\ModelTwo::class => 30,
],
```

This would purge any ModelOnes that were deleted over 14 days ago and any ModelTwos that were deleted over 30 days ago.

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity34

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity82

Battle-tested with a long release history

 Bus Factor1

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

###  Release Activity

Cadence

Every ~142 days

Recently: every ~315 days

Total

20

Last Release

1203d ago

Major Versions

0.5.0 → 1.0.02018-03-23

1.2.0 → 2.0.02019-02-15

PHP version history (3 changes)0.1.0PHP &gt;=5.5.0

2.0.0PHP &gt;=7.2

2.5.0PHP &gt;=8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/a082f934783fa6f391c37fc7e7ca71f84e17219471cadd17a8b8b85b42c2c9c1?d=identicon)[david.mathews](/maintainers/david.mathews)

![](https://www.gravatar.com/avatar/782b3ad6f100c625875d6a8f00222d0e08e0c6f0956ef757e43a38441594c013?d=identicon)[jimmypuckett](/maintainers/jimmypuckett)

![](https://www.gravatar.com/avatar/a03d6c15997b49e0fa73b6e61f6c4fbc833f1f0d2476984fe88bb38a8b866c2d?d=identicon)[ssfinney](/maintainers/ssfinney)

---

Top Contributors

[![jimmypuckett](https://avatars.githubusercontent.com/u/3220069?v=4)](https://github.com/jimmypuckett "jimmypuckett (154 commits)")[![ssfinney](https://avatars.githubusercontent.com/u/1596394?v=4)](https://github.com/ssfinney "ssfinney (65 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (2 commits)")[![StephenAntalis](https://avatars.githubusercontent.com/u/5741976?v=4)](https://github.com/StephenAntalis "StephenAntalis (1 commits)")

---

Tags

laravellaravel-5-packagelaravel-garbage-mansoft-deletesspinenlaravellibrarysoftdeletespinen

###  Code Quality

TestsPHPUnit

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/spinen-laravel-garbage-man/health.svg)

```
[![Health](https://phpackages.com/badges/spinen-laravel-garbage-man/health.svg)](https://phpackages.com/packages/spinen-laravel-garbage-man)
```

###  Alternatives

[laravel/cashier

Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services.

2.6k29.9M146](/packages/laravel-cashier)[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k15.1M132](/packages/laravel-pulse)[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[laravel/ai

The official AI SDK for Laravel.

1.0k3.2M194](/packages/laravel-ai)[flarum/core

Delightfully simple forum software.

201.4M2.3k](/packages/flarum-core)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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