Thursday, July 28, 2016

factory faker

factory faker step by step.

1. Add $factory on ModelFactory.php
$factory->define(App\Tenant::class, function (Faker\Generator $faker) {
    return [
        'name' => $faker->name,
        'nric' => $faker->numerify('######-##-####'),
        'dob' => $faker->date
    ];
});

2. run with php artisan tinker
 factory('App\Tenant',20)->create();

3. Reference.
https://github.com/fzaninotto/Faker

No comments:

Post a Comment