Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #32: Attach relationships to models in factory definitions #36

Closed
wants to merge 2 commits into from
Closed

Conversation

axit-joost
Copy link
Contributor

@axit-joost axit-joost commented Dec 11, 2019

This PR will add the ability for the FactoryGenerator to render a relationship definition.

Instead of:

$factory->define(Person::class, function (Faker $faker) {
    return [
        'additionalName' => $faker->word,
        'address_id' => $faker->randomDigitNotNull,
        'familyName' => $faker->word,
        'givenName' => $faker->word,
    ];
});

It will now yield:

$factory->define(Person::class, function (Faker $faker) {
    return [
        'additionalName' => $faker->word,
        'address_id' => factory(App\PostalAddress::class),
        'familyName' => $faker->word,
        'givenName' => $faker->word,
    ];
});

Using the factory to create a Person will also yield the creation of a PostalAddress.

PR includes an updated fixture to allow the test suite to get green.

If there's anything that needs to be changed, please let me know.

Cheers!

@jasonmccreary
Copy link
Collaborator

Thanks for this. I am closing to make some small adjustments and will merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants