This commit is contained in:
Duidev Software House
2025-09-09 20:07:05 +07:00
parent cf81c9503b
commit 9c261cd32d
6 changed files with 424 additions and 176 deletions
+27
View File
@@ -0,0 +1,27 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
use App\Poli;
class PoliSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
Poli::truncate();
$json1 = file_get_contents(database_path('seeders/data/poli.json'));
$data1 = json_decode($json1, true);
// Bagi data ke dalam batch 500
$chunks = array_chunk($data1, 500);
foreach ($chunks as $chunk) {
DB::table('poli')->insert($chunk);
}
}
}