PHP code example of outsidaz / laravel-data-anonymization

1. Go to this page and download the library: Download outsidaz/laravel-data-anonymization 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/ */

    

outsidaz / laravel-data-anonymization example snippets


return [
    'locale' => 'en_US',
    'chunk_size' => 1000,
    'models_path' => app_path('Models'),
    'models_namespace' => '\\App\\Models',
]


class User extends Authenticatable
{
    use Anonymizable;
    
    <...>

    public function anonymizableAttributes(Generator $faker): array
    {
        return [
            'email' => $this->id . '@custom.dev',
            'password' => 'secret',
            'firstname' => $faker->firstName,
            'surname' => $faker->lastName,
            'phone' => $faker->e164PhoneNumber,
            'position' => $faker->jobTitle,
            'token' => null,
        ];
    }
    
    // optional
    public function anonymizableCondition(): Builder
    {
        return self::withTrashed()->where('something', '=>', '...');
    }
}
bash
php artisan db:anonymize