PHP code example of yo1l / laravel-data-anonymization

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

    

yo1l / laravel-data-anonymization example snippets




namespace Database\Anonymization;

use Arrilot\LaravelDataAnonymization\AbstractAnonymizer;

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




namespace Database\Anonymization;

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

class UsersAnonymizer 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');
        });
    }
}