-
Notifications
You must be signed in to change notification settings - Fork 10.7k
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
Multiple factories not resetting each time #13534
Comments
I don't see how this can be happening. It sounds more like a bug in your code. Feel free to discuss on the forums, and come back here if you have really small case that we can reproduce on a stock app. |
Just managed to replicate the issue on a fresh install using Model Factory:$factory->define(App\Team::class, function (Faker\Generator $faker) {
return [
'name' => $faker->word,
'primary_colour' => $faker->hexColor
];
}); DatabaseSeeder.php public function run()
{
$this->call(TeamSeeder::class);
} Migration (SQLite) Schema::create('teams', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('primary_colour');
$table->timestamps();
}); Modelclass Team extends Model
{
//
} Team Seederclass TeamSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
factory(Team::class, 1)->create()->each(function() {
echo "Seeder 1";
});
factory(Team::class, 1)->create()->each(function() {
echo "Seeder 2";
});
}
} Output
Also worth noting, each time I run the seeder:
|
Ping @taylorotwell |
This is not a bug. Calling Just don't call |
In my seeder I'm calling a factory on a class multiple times. Each time, I only create 1 new model, however, my
->each()
function is carrying across models created from the previous calls.E.g.
Using v5.2.31
The text was updated successfully, but these errors were encountered: