PHP code example of will2therich / laravel-model-anonymizer

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

    

will2therich / laravel-model-anonymizer example snippets


namespace App\Anonymize;

use Faker\Factory;
use Illuminate\Database\Eloquent\Model;
use will2therich\LaravelModelAnonymizer\Contracts\AnonymizeInterface;

class User implements AnonymizeInterface
{
    public static $model = \App\Models\User::class;

    public static $name = "User";

    public static function anonymize(Model $model)
    {
        $faker = Factory::create();
    
        $model->email = $faker->unique()->email();
        $model->save();
    }

}