<?php

declare(strict_types=1);

namespace Database\Factories;

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

/** @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Invoice> */
class InvoiceFactory extends Factory
{
    /** @return array<string, mixed> */
    public function definition(): array
    {
        return [
            'user_id' => User::factory(),
            'gateway' => 'stripe',
            'number' => 'INV-'.fake()->unique()->numerify('######'),
            'total' => fake()->randomFloat(2, 5, 500),
            'tax' => fake()->randomFloat(2, 0, 50),
            'currency' => 'USD',
            'status' => fake()->randomElement(['draft', 'sent', 'paid', 'overdue']),
            'due_date' => fake()->dateTimeBetween('now', '+30 days'),
        ];
    }

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