Update
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user