PHP code example of atabix / laravel-data-anonymization

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

    

atabix / laravel-data-anonymization example snippets




use Arrilot\LaravelDataAnonymization\AbstractAnonymizer;

class DatabaseAnonymizer extends AbstractAnonymizer
{
    /**
     * Run the database anonymization.
     *
     * @return void
     */
    public function run()
    {
        $this->call(UserTableAnonymizer::class);
    }
}




use Arrilot\DataAnonymization\Blueprint;
use Arrilot\LaravelDataAnonymization\AbstractAnonymizer;
use Faker\Generator as Faker;

class UserTableAnonymizer extends AbstractAnonymizer
{
    /**
     * Run the database anonymization.
     *
     * @return void
     */
    public function run()
    {
        // For more info about this part read here https://github.com/arrilot/data-anonymization
        $this->table('users', function (Blueprint $table) {

            $table->column('email')->replaceWith(function(Faker $faker) {
                return $faker->unique()->email;
            });

            $table->column('name')->replaceWith('John Doe');
        });
    }
}