The hardest thing to read. Use capital letters, commas, new sentences, etc...
foreach(range(1, 200000) as $i) {
$data[] = [
'name' => sprintf('Name %s', $i),
'email' => sprintf('user%[email protected]', $i),
// and so on...
];
}
$chunks = array_chunk($data, 1000);
foreach($chunks as $chunk) {
User::query()->insert($chunk);
}
You can also use following:
DB::unprepared();
foreach(range(1, 200000) as $i) {
$data[] = [
'name' => sprintf('Name %s', $i),
'email' => sprintf('user%[email protected]', $i),
// and so on...
];
}
User::query()->insert($data);