forss-it / laravel-gdpr-compliance

GDPR compliant data handling with ease
54 stars 5 forks source link

When anonymizing a user I dont want to anonymize relations #57

Closed dsbilling closed 5 years ago

dsbilling commented 5 years ago

When anonymizing a user it is anonymizing relations, I dont want that. I prefer to delete it with another function. Is there a way to skip that when running anonymize on a user?

I have added $gdprWith relations for the download, but don't need them to anonymize.

mgc2222 commented 5 years ago

Hi, if you don't want to anonimize relations just don't use gdprAnonymizableFields attribute in the related models, The anonymize function will do the job, looping through all related models, only if gdprAnonymizableFields attribute is not null.

dsbilling commented 5 years ago

@mgc2222 That throws an error.

As a workaround I did this and nothing more:

<?php 

namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Dialect\Gdpr\Anonymizable;  <<<<<=====

class ModelName extends Model {

    use Anonymizable; <<<<<=====

    protected $fillable = [
        'field'
    ];
    protected $table = 'modelname';

}
dsbilling commented 5 years ago

I guess the another solution to this is:

    protected $gdprWith = null;
dsbilling commented 5 years ago

But now everything works without, dont know why I this was a issue in the first place. Closing.