*/ final class CustomerFactory extends Factory { protected $model = Customer::class; public function definition(): array { $type = fake()->randomElement(['individual', 'company']); return [ 'name' => fake()->name(), 'company_name' => $type === 'company' ? fake()->company() : null, 'type' => $type, 'email' => fake()->optional()->safeEmail(), 'phone' => fake()->optional()->phoneNumber(), 'address' => fake()->optional()->streetAddress(), 'city' => fake()->optional()->city(), 'postal_code' => fake()->optional()->postcode(), 'country' => 'NL', 'notes' => fake()->optional()->paragraph(), 'is_portal_enabled' => fake()->boolean(20), ]; } public function individual(): static { return $this->state(fn () => [ 'type' => 'individual', 'company_name' => null, ]); } public function company(): static { return $this->state(fn () => [ 'type' => 'company', 'company_name' => fake()->company(), ]); } public function withPortal(): static { return $this->state(fn () => ['is_portal_enabled' => true]); } }