<?php
namespace Database\Factories;

use App\Models\Candidat;
use App\Models\Quartier;
use Illuminate\Database\Eloquent\Factories\Factory;

class ParrainFactory extends Factory
{
    public function definition(): array
    {
        return [
            'candidat_id'          => Candidat::factory(),
            'nom_complet'          => fake()->name(),
            'lien_avec_candidat'   => fake()->randomElement(['parent', 'voisin', 'chef_quartier', 'ami', 'collegue', 'autre']),
            'telephone_principal'  => '+237 6' . fake()->numerify('## ### ###'),
            'telephone_secondaire' => fake()->optional()->phoneNumber(),
            'email'                => fake()->optional()->safeEmail(),
            'quartier_id'          => Quartier::inRandomOrder()->first()?->id,
            'adresse_domicile'     => fake()->address(),
            'a_signe_contrat'      => false,
            'contrat_signe_at'     => null,
        ];
    }

    public function contratSigne(): static
    {
        return $this->state(fn() => [
            'a_signe_contrat'  => true,
            'contrat_signe_at' => now()->subDays(fake()->numberBetween(1, 30)),
        ]);
    }
}
