F
Filament11mo ago
AlexDev

Question about project filament and seed withProgressBar

Hi all! In the seeder file using method withProgressBar
$user = $this->withProgressBar(1, fn () => User::factory(1)->create([
'name' => 'Demo User',
'email' => '[email protected]',
]));
$user = $this->withProgressBar(1, fn () => User::factory(1)->create([
'name' => 'Demo User',
'email' => '[email protected]',
]));
I don't understand how to add another user with email to get something like this? And get a progressbar with a corresponding counter of 2, since it would have two records as one in this case:
$user = $this->withProgressBar(1, fn () => User::factory(1)->sequence([
'name' => 'Demo Admin',
'email' => '[email protected]',
],[
'name' => 'Demo User',
'email' => '[email protected]',
])->create());
$user = $this->withProgressBar(1, fn () => User::factory(1)->sequence([
'name' => 'Demo Admin',
'email' => '[email protected]',
],[
'name' => 'Demo User',
'email' => '[email protected]',
])->create());
GitHub
demo/database/seeders/DatabaseSeeder.php at b3090a325996b978dd75fa6...
Source code for the demo.filamentphp.com website. Contribute to filamentphp/demo development by creating an account on GitHub.
2 Replies
Tieme
Tieme11mo ago
Gist
Progress bar for seed, Laravel
Progress bar for seed, Laravel. GitHub Gist: instantly share code, notes, and snippets.
AlexDev
AlexDevOP11mo ago
Your code works well (thanks), and in the demo example on github too (seed 2 fake users):
$this->withProgressBar(2, fn () => User::factory(1)->create());
$this->withProgressBar(2, fn () => User::factory(1)->create());
I want to get the two users preseeded: admin and user, and then already fill in the rest of the seeded ones.
Want results from more Discord servers?
Add your server