isEmpty()) { $this->command->warn('Product table is empty. Please run ProductSeeder first.'); return; } foreach ($branches as $branch) { // Seed Purchases for ($i = 0; $i < 5; $i++) { $product = $products->random(); Purchase::create([ 'date' => Carbon::now()->subDays(rand(1, 10))->toDateString(), 'branch' => $branch, 'product_id' => $product->id, 'item' => $product->name, 'quantity' => rand(1, 10) . ' Pack', 'total_price' => rand(20000, 200000), ]); } // Seed Sales for ($i = 0; $i < 10; $i++) { $product = $products->random(); Sale::create([ 'date' => Carbon::now()->subDays(rand(0, 5))->toDateString(), 'branch' => $branch, 'product_id' => $product->id, 'item' => $product->name, 'quantity' => rand(1, 5), 'total_price' => $product->selling_price * rand(1, 5), ]); } } } }