<?php

namespace Database\Factories;

use App\Models\Client;
use App\Models\User;
use App\Models\Ville;
use App\Models\Quartier;
use Illuminate\Database\Eloquent\Factories\Factory;

class ClientFactory extends Factory
{
    public function definition(): array
    {
        return [
            'user_id' => User::factory()->client(),
            'type_client' => fake()->randomElement(['particulier', 'entreprise', 'evenementiel']),
            'nom_complet' => fake()->name(),
            'raison_sociale' => fake()->randomElement([null, fake()->company()]),
            'nom_contact' => fake()->name(),
            'telephone_principal' => fake()->phoneNumber(),
            'telephone_secondaire' => fake()->optional()->phoneNumber(),
            'adresse_complete' => fake()->address(),
            'quartier_id' => Quartier::inRandomOrder()->first()?->id,
            'ville_id' => Ville::factory(),
            'client_depuis' => fake()->optional()->date(),
        ];
    }

    public function particulier(): static
    {
        return $this->state(fn (array $attributes) => [
            'type_client' => 'particulier',
        ]);
    }

    public function entreprise(): static
    {
        return $this->state(fn (array $attributes) => [
            'type_client' => 'entreprise',
        ]);
    }

    public function profilComplet(): static
    {
        return $this->state(fn (array $attributes) => [
            'type_client' => 'particulier',
            'nom_complet' => fake()->name(),
            'telephone_principal' => fake()->phoneNumber(),
            'ville_id' => Ville::factory(),
        ]);
    }

    public function profilIncomplet(): static
    {
        return $this->state(fn (array $attributes) => [
            'type_client' => 'particulier',
            'nom_complet' => '',
            'telephone_principal' => '',
            'ville_id' => Ville::factory(),
        ]);
    }
}
