PHPackages                             romanzipp/laravel-previously-deleted - 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. romanzipp/laravel-previously-deleted

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

romanzipp/laravel-previously-deleted
====================================

Store previously deleted Model attributes

1.7.0(1y ago)312.7k↑50%MITPHPPHP ^8.0CI passing

Since Sep 10Pushed 1y ago1 watchersCompare

[ Source](https://github.com/romanzipp/Laravel-Previously-Deleted)[ Packagist](https://packagist.org/packages/romanzipp/laravel-previously-deleted)[ GitHub Sponsors](https://github.com/romanzipp)[ RSS](/packages/romanzipp-laravel-previously-deleted/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (8)Versions (22)Used By (0)

Laravel Previously Deleted
==========================

[](#laravel-previously-deleted)

[![Latest Stable Version](https://camo.githubusercontent.com/6411c22edf9a685026d5e3c4d8f8bc68a6b2c03738d3455c10516928755c0013/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f726f6d616e7a6970702f6c61726176656c2d70726576696f75736c792d64656c657465642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/romanzipp/laravel-previously-deleted)[![Total Downloads](https://camo.githubusercontent.com/96121f216ebe449fd0df5bf577a5da8de000894d76d217376365abf5cd0ac868/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f726f6d616e7a6970702f6c61726176656c2d70726576696f75736c792d64656c657465642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/romanzipp/laravel-previously-deleted)[![License](https://camo.githubusercontent.com/f1d15cc3b9698ec212a80e83184d15fd059ccc2f34206a309992784cdc40d036/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f726f6d616e7a6970702f6c61726176656c2d70726576696f75736c792d64656c657465642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/romanzipp/laravel-previously-deleted)[![GitHub Build Status](https://camo.githubusercontent.com/0186edc5197d66f2e089d63683814b5f8451bbec0249329e91718926f0e89a65/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f726f6d616e7a6970702f4c61726176656c2d50726576696f75736c792d44656c657465642f74657374732e796d6c3f6272616e63683d6d6173746572266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/romanzipp/Laravel-Previously-Deleted/actions)

This package stores selected attributes of Models before deletion.

Why?
----

[](#why)

If a user requests a deletion of their user data, you are partially required to remove all data related to the user (GDPR). With this package, you can store certain attributes &amp; values e.g. to block previously registered usernames oder email addresses.

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

[](#installation)

```
composer require romanzipp/laravel-previously-deleted

```

**If you use Laravel 5.5+ you are already done, otherwise continue:**

```
romanzipp\PreviouslyDeleted\Providers\PreviouslyDeletedProvider::class,
```

Add Service Provider to your app.php configuration file:

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

[](#configuration)

Copy configuration to config folder:

```
$ php artisan vendor:publish --provider="romanzipp\PreviouslyDeleted\Providers\PreviouslyDeletedProvider"

```

Run the migration:

```
$ php artisan migrate

```

Usage
-----

[](#usage)

This example shows the usage with a User model and stored "username" and "email" attributes.

### Add Model Trait

[](#add-model-trait)

```
use romanzipp\PreviouslyDeleted\Traits\SavePreviouslyDeleted;

class User extends Model
{
    use SavePreviouslyDeleted;

    protected $storeDeleted = [
        'username',
        'email',
    ];
}
```

### Add Validation Rule

[](#add-validation-rule)

The validation rule takes 2 arguments: `not_deleted:{table}[,{attribute}]`

- `table`: The queried table name. In this exmaple: `users`.
- `attribute`: The model attribute. If not given, the input name will be used.

```
public function store(Request $request)
{
    $request->validate([
        'name' => ['required', 'not_deleted:users,username'],
        'email' => ['required', 'not_deleted:users'],
        'password' => ['required', 'min:6']
    ]);

    User::create([
        'username' => $request->input('name'),
        'email' => $request->input('email'),
        'password' => bcrypt($request->input('password')),
    ]);
}
```

You can also use a rule instance:

```
use romanzipp\PreviouslyDeleted\Rules\NotPreviouslyDeleted;

$request->validate([
    'name' => ['required', new NotPreviouslyDeleted(User::class, 'username')],
    'email' => ['required', new NotPreviouslyDeleted(User::class)],
    'password' => ['required', 'min:6']
]);
```

Extended Usage
--------------

[](#extended-usage)

### Storing hashed values

[](#storing-hashed-values)

When storing personal information you should create hashes to respect your users privacy.

**Store plain-text values**

```
protected $storeDeleted = [
    'username',
    'email',
];
```

With the GDPR (DSGVO) a user has the right to request a full deletion of all personal information, including email address, username etc. If you're affected by this, you should make use of hashing algorythms to prevent any harm of privacy.

**Store hashed values**

```
protected $storeDeleted = [
    'username' => 'sha1',
    'email' => 'md5',
];
```

### Storing soft deletes

[](#storing-soft-deletes)

By default, the package only stores attributes if the model is being force-deleted.

To enable storing attributes even in soft-deletion, set the `ignore_soft_deleted` config value to `false`.

```
return [
    'ignore_soft_deleted' => false,
];
```

Testing
-------

[](#testing)

```
./vendor/bin/phpunit
```

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance46

Moderate activity, may be stable

Popularity26

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity76

Established project with proven stability

 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

Every ~119 days

Recently: every ~284 days

Total

21

Last Release

418d ago

PHP version history (4 changes)1.0.0PHP &gt;=7.0

1.1.0PHP ^7.2

1.2.4PHP ^7.2|^8.0

1.6.0PHP ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/309ea408cc915d1d37b370796df57a24ec31f0b65da69f69c650c8983f9c33a6?d=identicon)[romanzipp](/maintainers/romanzipp)

---

Top Contributors

[![romanzipp](https://avatars.githubusercontent.com/u/11266773?v=4)](https://github.com/romanzipp "romanzipp (71 commits)")

---

Tags

gdprlaravelphpphp7privacyshowcase

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/romanzipp-laravel-previously-deleted/health.svg)

```
[![Health](https://phpackages.com/badges/romanzipp-laravel-previously-deleted/health.svg)](https://phpackages.com/packages/romanzipp-laravel-previously-deleted)
```

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[orchestra/canvas

Code Generators for Laravel Applications and Packages

21017.2M158](/packages/orchestra-canvas)[kirschbaum-development/commentions

A package to allow you to create comments, tag users and more

12369.2k](/packages/kirschbaum-development-commentions)[aedart/athenaeum

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

255.2k](/packages/aedart-athenaeum)[glhd/special

1929.4k](/packages/glhd-special)[bjuppa/laravel-blog

Add blog functionality to your Laravel project

483.3k2](/packages/bjuppa-laravel-blog)

PHPackages © 2026

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