[ ['code' => 'OLI001', 'name' => 'Oli Mesin 10W-40', 'subcategory' => 'Oli Mesin', 'unit' => 'liter'], ['code' => 'OLI002', 'name' => 'Oli Mesin 20W-50', 'subcategory' => 'Oli Mesin', 'unit' => 'liter'], ['code' => 'OLI003', 'name' => 'Oli Gardan SAE 90', 'subcategory' => 'Oli Gardan', 'unit' => 'liter'], ['code' => 'OLI004', 'name' => 'Minyak Rem DOT 3', 'subcategory' => 'Minyak Rem', 'unit' => 'ml'], ['code' => 'OLI005', 'name' => 'Grease Serbaguna', 'subcategory' => 'Pelumas Lain', 'unit' => 'gram'], ], // Aki & Kelistrikan 'Aki & Kelistrikan' => [ ['code' => 'AKI001', 'name' => 'Aki Kering 12V 5Ah', 'subcategory' => 'Aki', 'unit' => 'pcs'], ['code' => 'AKI002', 'name' => 'Aki Basah 12V 7Ah', 'subcategory' => 'Aki', 'unit' => 'pcs'], ['code' => 'AKI003', 'name' => 'Lampu LED Headlight', 'subcategory' => 'Lampu', 'unit' => 'pcs'], ['code' => 'AKI004', 'name' => 'Sekring 10A', 'subcategory' => 'Kelistrikan', 'unit' => 'pcs'], ['code' => 'AKI005', 'name' => 'Regulator Rectifier', 'subcategory' => 'Kelistrikan', 'unit' => 'pcs'], ], // Rem 'Rem' => [ ['code' => 'REM001', 'name' => 'Kampas Rem Depan Motor', 'subcategory' => 'Kampas Rem', 'unit' => 'set'], ['code' => 'REM002', 'name' => 'Kampas Rem Belakang Motor', 'subcategory' => 'Kampas Rem', 'unit' => 'set'], ['code' => 'REM003', 'name' => 'Cakram Rem Depan Mobil', 'subcategory' => 'Cakram', 'unit' => 'pcs'], ['code' => 'REM004', 'name' => 'Minyak Rem DOT 4', 'subcategory' => 'Minyak Rem', 'unit' => 'ml'], ['code' => 'REM005', 'name' => 'Master Rem Depan', 'subcategory' => 'Master Rem', 'unit' => 'pcs'], ], // Cuci Kendaraan & Perawatan 'Cuci Kendaraan' => [ ['code' => 'CUCI001', 'name' => 'Shampoo Mobil PH Netral', 'subcategory' => 'Shampoo', 'unit' => 'liter'], ['code' => 'CUCI002', 'name' => 'Sabun Cuci Motor Anti Karat', 'subcategory' => 'Shampoo', 'unit' => 'liter'], ['code' => 'CUCI006', 'name' => 'Semir Ban Botol 500ml', 'subcategory' => 'Perawatan Eksterior', 'unit' => 'ml'], ['code' => 'CUCI007', 'name' => 'Snow Foam Cuci Mobil', 'subcategory' => 'Shampoo', 'unit' => 'liter'], ['code' => 'CUCI008', 'name' => 'Pembersih Interior Dashboard', 'subcategory' => 'Perawatan Interior', 'unit' => 'ml'], ['code' => 'CUCI009', 'name' => 'Wax Body Mobil', 'subcategory' => 'Perawatan Eksterior', 'unit' => 'ml'], ['code' => 'CUCI010', 'name' => 'Pembersih Kaca Anti Jamur', 'subcategory' => 'Perawatan Kaca', 'unit' => 'ml'], ], ]; foreach ($categories as $parentName => $products) { // Create parent category $parent = ProductCategory::firstOrCreate( ['name' => $parentName], ['created_at' => now(), 'updated_at' => now()] ); foreach ($products as $product) { // Create child category (sub-category) $child = ProductCategory::firstOrCreate( ['name' => $product['subcategory'], 'parent_id' => $parent->id], ['created_at' => now(), 'updated_at' => now()] ); // Create product in the child category Product::updateOrCreate( ['code' => $product['code']], [ 'name' => $product['name'], 'description' => $product['name'], 'product_category_id' => $child->id, 'unit' => $product['unit'], ] ); } } } }