PHP code example of alializade / laravel-masked-db-dump

1. Go to this page and download the library: Download alializade/laravel-masked-db-dump 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/ */

    

alializade / laravel-masked-db-dump example snippets


use AliAlizade\LaravelMaskedDumper\DumpSchema;
use AliAlizade\LaravelMaskedDumper\TableDefinitions\TableDefinition;
use Faker\Generator as Faker;

class CoreServiceProvider extends ServiceProvider
{
    // ...
    public function boot(): void
    {
        //... 
        
        $this->app->singleton('masked_dump_default', function () {
            return DumpSchema::define('mysql')
                ->allTables()
                ->table('users', function (TableDefinition $table) {
                    $table->replace('name', function (Faker $faker) {
                        return $faker->name;
                    });
                    $table->replace('email', function (Faker $faker) {
                        return $faker->lastName().'@fake.com';
                    });
                    $table->replace('password', function (Faker $faker) {
                        return $password = bcrypt('secret');
                    });
                })
                ->schemaOnly('personal_access_tokens')
        });
        // ...
}