Factory count don't work ? Hello everyone, I'm starting Laravel after several years of CakePHP. I want to add data to my database and despite my code it only adds one row.
I'm not sure where it could come from?
class EventSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
Event::factory()->count(50)->create();
}
}
public function definition(): array
{
return [
'title' => fake()->sentence(),
'slug' => Str::slug(fake()->sentence()),
'description' => fake()->text(),
];
}
I've found ! I had placed this code to try to create a slug during the manual creation but by doing the migration to create the slug column this created the problem.
protected static function booted() : void
{
static::saved(function (Event $event){
dd($event->title);
});
}
Please sign in or create an account to participate in this conversation.