Created
August 15, 2020 14:09
-
-
Save grandmanitou/2e36f9a128defdf502fd697eec51cb0a to your computer and use it in GitHub Desktop.
Use faker with 3rd party class in a Laravel factory
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use App\User; | |
use Illuminate\Support\Str; | |
use Faker\Generator as Faker; | |
$factory->define(User::class, function (Faker $faker) { | |
$faker->addProvider(new CompanyNameGenerator\FakerProvider($faker)); | |
return [ | |
'first_name' => $faker->firstName, | |
'last_name' => $faker->lastName, | |
'role' => 'user', | |
'email' => $faker->unique()->safeEmail, | |
'email_verified_at' => now(), | |
'username' => $faker->companyName, | |
'password' => Str::random(50), | |
'remember_token' => Str::random(10), | |
'created_at' => now(), | |
'updated_at' => now(), | |
]; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment