*/ class PurchaseFactory extends Factory { public function definition(): array { $subtotal = fake()->numberBetween(100_000, 10_000_000); $discount = fake()->numberBetween(0, (int) ($subtotal * 0.1)); return [ 'supplier_id' => Supplier::factory(), 'created_by_id' => User::factory(), 'subtotal' => $subtotal, 'discount' => $discount, 'total' => $subtotal - $discount, 'notes' => fake()->optional()->sentence(3), ]; } }