<?php
namespace Database\Factories;

use App\Models\Signalement;
use App\Models\Mission;
use App\Models\Client;
use Illuminate\Database\Eloquent\Factories\Factory;

class SignalementFactory extends Factory
{
    protected $model = Signalement::class;

    public function definition(): array
    {
        return [
            'type_signalement' => fake()->randomElement(['absence', 'retard', 'comportement', 'vol', 'degat', 'qualite', 'autre']),
            'description' => fake()->paragraph(),
            'gravite' => fake()->randomElement(['faible', 'moyen', 'grave', 'critique']),
            'statut' => 'recu',
            'traite_par' => fake()->optional()->numberBetween(1, 10),
            'resolution' => fake()->optional()->paragraph(),
            'date_resolution' => fake()->optional()->dateTimeBetween('now', '+7 days'),
        ];
    }

    public function forClient(Client $client): static
    {
        return $this->state(fn (array $attributes) => [
            'client_id' => $client->id,
        ]);
    }

    public function forMission(Mission $mission): static
    {
        return $this->state(fn (array $attributes) => [
            'mission_id' => $mission->id,
            'client_id' => $mission->client_id,
        ]);
    }
}
