Skip to content

Conversation

@sebdesign
Copy link
Contributor

The factory method can be called in a number of ways:

// Without arguments
User::factory();

// With count
User::factory(3);

// With count and array state
User::factory(3, ['account_status' => 'suspended']);

// With count and closure state
User::factory(3, function (array $attributes) {
    return ['account_status' => 'suspended'];
});

// With array state
User::factory(['account_status' => 'suspended']);

// With closure state
User::factory(function (array $attributes) {
    return ['account_status' => 'suspended'];
});

This PR adds docblocks for the possible arguments and cleans up the parameter overloading.

@GrahamCampbell GrahamCampbell changed the title Improve signature for HasFactory::factory() [9.x] Improve signature for HasFactory::factory() Sep 8, 2020
@taylorotwell taylorotwell merged commit 0f0f883 into laravel:master Sep 10, 2020
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.

2 participants