<?php

declare(strict_types=1);

namespace Database\Factories;

use App\Models\Affiliate;
use App\Models\AffiliateReferral;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;

/** @extends Factory<AffiliateReferral> */
class AffiliateReferralFactory extends Factory
{
    protected $model = AffiliateReferral::class;

    /** @return array<string, mixed> */
    public function definition(): array
    {
        return [
            'affiliate_id' => Affiliate::factory(),
            'referred_user_id' => User::factory(),
            'subscription_id' => null,
            'status' => 'pending',
            'signup_ip' => fake()->ipv4(),
            'referral_url' => fake()->url(),
        ];
    }

    public function approved(): static
    {
        return $this->state(fn (): array => [
            'status' => 'approved',
            'approved_at' => now(),
        ]);
    }

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