PHP code example of dansoppelsa / carwash

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

    

dansoppelsa / carwash example snippets




return [
    'users' => [
        'first_name' => 'firstName',
        'last_name' => 'lastName',
        'email' => 'safeEmail'
    ],
    'addresses' => [
        'street' => 'streetAddress',
        'city' => 'city',
        'zip' => 'postcode'
    ],
   'bios' => [
        'content' => 'sentences:2'   
    ]
];



return [
    '[TABLE_NAME]' => [
        '[COLUMN_NAME]' => '[Faker Formatter][:argument1,argument2]'
    ]
];

php artisan carwash:scrub



return [
    'users' => [
        'name' => function ($faker, $currentValue) {
            return "{$faker->firstName} {$faker->lastName}";
        },
        'bio' => new BioFormatter
    ]
];

class BioFormatter
{
    public function __invoke($faker)
    {
        return $faker->sentences(42);
    }
}



return [
    'users' => function ($faker, $user) {
        $firstName = $faker->firstName;
        $lastName = $faker->lastName;
    
        return [
            'first_name' => $firstName,
            'last_name' => $lastName,
            'email' => $firstName . "." . $lastName. "@" . $faker->safeEmailDomain,
            'phone' => substr($user['phone'], 0, 3) . "-555-" . $faker->randomNumber(4)
        ];
    },
];

php artisan vendor:publish