insert([ 'tipe_peti_id' => $this->getRandomId('type_petis'), 'warna' => 'Dummy Warna ' . ($i + 1), 'fix_lot' => 'Dummy Fix Lot ' . ($i + 1), 'packing_no' => rand(1, 100), 'customer_id' => $this->getRandomId('customers'), 'jumlah' => rand(1, 10), 'date_pembuatan' => now(), 'warehouse_id' => $this->getRandomId('m_warehouses'), 'kondisipeti_id' => $this->getRandomId('kondisi_petis'), 'status' => 'AKTIF', 'created_at' => now(), 'updated_at' => now(), 'created_by' => 'Seeder', 'updated_by' => 'Seeder', ]); } } /** * Get a random ID from a specific table * * @param string $tableName * @return string|null */ protected function getRandomId($table) { return DB::table($table)->inRandomOrder()->first()->id; } }