PHP code example of ginkelsoft / laravel-data-right-to-be-forgotten

1. Go to this page and download the library: Download ginkelsoft/laravel-data-right-to-be-forgotten library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ginkelsoft / laravel-data-right-to-be-forgotten example snippets


use Ginkelsoft\DataRightToBeForgotten\Attributes\Forgettable;
use Ginkelsoft\DataRightToBeForgotten\Concerns\Forgettable as ForgettableTrait;
use Ginkelsoft\DataRightToBeForgotten\Contracts\Forgettable as ForgettableContract;

#[Forgettable(column: 'id', action: 'delete')]
class User extends Model implements ForgettableContract
{
    use ForgettableTrait;
}

#[Forgettable(column: 'user_id', action: 'delete')]
class Order extends Model implements ForgettableContract
{
    use ForgettableTrait;
}

class Profile extends Model implements ForgettableContract
{
    use ForgettableTrait;

    protected array $forgettable = [
        'column'    => 'user_id',
        'action'    => 'anonymize',
        'anonymize' => [
            'first_name' => 'placeholder',
            'last_name'  => 'placeholder',
            'email'      => 'hash',
        ],
    ];
}

// config/forget.php
return [
    'models' => [
        \App\Models\User::class,
        \App\Models\Profile::class,
        \App\Models\Order::class,
    ],
    '

use Ginkelsoft\ComplianceCore\Config\LogSecret;
use Ginkelsoft\ComplianceCore\Support\HashChain;
use Illuminate\Support\Facades\DB;

$entries = DB::table('forget_log')->orderBy('id')->get()
    ->map(fn ($row) => (array) $row)->all();

$intact = HashChain::verify($entries, LogSecret::value());

  use Ginkelsoft\DataRightToBeForgotten\Concerns\Forgettable;
  use Ginkelsoft\DataSubjectAccess\Concerns\Exportable;
  class User extends Model implements ExportableContract, ForgettableContract
  {
      use Exportable, Forgettable {
          Forgettable::forSubjectQuery insteadof Exportable;
      }
  }
  
bash
php artisan retention:forget 01HXYZ --dry-run
php artisan retention:forget 01HXYZ