isEmpty()) { User::factory(5)->create(); $users = User::all(); } // Create 30 random expenses over the last 6 months Expense::factory(30)->create([ 'created_at' => now()->subMonths(rand(0, 5))->subDays(rand(0, 28)), ]); // Add some specific common expenses $commonExpenses = ['Listrik Toko', 'Wifi Bulanan', 'Sampah Bulanan', 'Air']; foreach (range(1, 6) as $month) { $date = now()->subMonths($month)->startOfMonth(); foreach ($commonExpenses as $name) { Expense::create([ 'user_id' => $users->random()->id, 'name' => $name, 'amount' => rand(50000, 500000), 'created_at' => $date->copy()->addDays(rand(0, 28)), ]); } } } }