'Nasi Goreng', 'category' => 'makanan', 'purchase_price' => 10000, 'selling_price' => 15000, ], [ 'name' => 'Mie Goreng', 'category' => 'makanan', 'purchase_price' => 7000, 'selling_price' => 10000, ], [ 'name' => 'Kopi Hitam', 'category' => 'minuman', 'purchase_price' => 3000, 'selling_price' => 5000, ], [ 'name' => 'Es Teh', 'category' => 'minuman', 'purchase_price' => 2000, 'selling_price' => 4000, ], [ 'name' => 'Keripik Kentang', 'category' => 'snack', 'purchase_price' => 4000, 'selling_price' => 7000, ], ]; $branches = ['Cabang 1', 'Cabang 2', 'Cabang 3']; foreach ($products as $pData) { $product = Product::create($pData); // Seed stock for each branch foreach ($branches as $branch) { Stock::create([ 'product_id' => $product->id, 'branch' => $branch, 'quantity' => rand(5, 50), 'unit' => $this->getUnit($product->category) ]); } } } private function getUnit($category) { switch ($category) { case 'makanan': return 'Porsi'; case 'minuman': return 'Gelas'; default: return 'Pcs'; } } }