mpociot/laravel-test-factory-helper

Convert relation column id to closure

ajcastro opened this issue · 1 comments

Instead of

$factory->define(App\User::class, function (Faker\Generator $faker) {
    return [
        'company_id' => factory(App\Company::class)->create()->id,
    ];
});

it should be

$factory->define(App\User::class, function (Faker\Generator $faker) {
    return [
        'company_id' => function() {
              return factory(App\Company::class)->create();
         },
    ];
});

This is what it was before, which seems unnecessary.

However, there is already a PR open to readdress this in #37. So I am closing this in favor of completing the change there. Feel free to add your suggestions to it.