<?php

declare(strict_types=1);

namespace Database\Factories;

use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use Laravel\Cashier\Subscription;

/**
 * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\CancellationSurvey>
 */
class CancellationSurveyFactory extends Factory
{
    /**
     * @return array<string, mixed>
     */
    public function definition(): array
    {
        return [
            'user_id' => User::factory(),
            'subscription_id' => Subscription::factory(),
            'cancellation_reason' => fake()->randomElement([
                'Too expensive',
                'No longer needed',
                'Switching to competitor',
                'Poor performance',
                'Missing features',
                'Technical issues',
                'Other',
            ]),
            'cancellation_feedback' => null,
            'would_return' => null,
        ];
    }

    public function withFeedback(): static
    {
        return $this->state(fn (array $attributes) => [
            'cancellation_feedback' => fake()->sentence(),
        ]);
    }

    public function wouldReturn(): static
    {
        return $this->state(fn (array $attributes) => [
            'would_return' => fake()->randomElement(['yes', 'maybe', 'no']),
        ]);
    }
}
