This is not possible using default Factory behavior.
You will have to keep an identity map in your seeder to regenerate the entity.
Summer Sale! All accounts are 50% off this week.
In Laravel 8 I have seeder like :
$photoNominations = PhotoNomination::factory()->count(15)->create([
]);
and Factory
class PhotoNominationFactory extends Factory
{
protected $model = PhotoNomination::class;
public function definition()
{
return [
'photo_id' => $this->faker->randomElement(Photo::all())['id'],
'nomination_id' => $this->faker->randomElement(Nomination::all())['id'],
];
}
}
How can I get all rows without repeated by 2 fields photo_id and nomination_id ?
Thanks!
Please or to participate in this conversation.