If you are affected by GDPR, you may find yourself in situation, when someone ask you to delete his/her data. You don't need to delete their records, just hide the sensible fields. This way your database remains consistent (eg. for history, statistics) but you finally satisfy the request.
With this package you can easily "nullify" specific fields for any Eloquent Model.
Laravel 5.5
Install with composer
composer require subdesign/laravel-gdpr-nullify:^1.0.0
Add the following trait to your Eloquent model
use Subdesign\LaravelGdprNullify\GdprNullifyTrait;
class YourModel extends Model {
use GdprNullifyTrait;
...
}
Next, add a property to this model which field(s) you want to nullify
protected $gdprFields = ['name', 'email'];
Use the nullify()
method on a model instance
$user = App\User::find(1);
$user->nullify();
In the example, the name
and email
fields will be filled with random characters in the length of the database fields.
The package has a dependency which is automatically installed: https://github.com/doctrine/dbal/tree/2.9
The MIT License (MIT). Please see License File for more information.