*/ class HostFactory extends Factory { protected $model = Host::class; public function definition(): array { return [ 'name' => 'pve-test-'.$this->faker->unique()->numberBetween(1, 99999), 'datacenter' => 'fsn', 'public_ip' => $this->faker->unique()->ipv4(), 'status' => 'pending', ]; } public function active(): static { return $this->state(function () { // Unique WG IP over a large space — a plain random last octet collides // (birthday paradox) when a test creates several active hosts. $n = $this->faker->unique()->numberBetween(1, 16_000_000); return [ 'status' => 'active', 'wg_ip' => '10.'.(($n >> 16) & 255).'.'.(($n >> 8) & 255).'.'.($n & 255), 'total_gb' => 1000, 'total_ram_mb' => 65536, 'cpu_cores' => 16, 'cpu_weight' => 16, ]; }); } }