<?php

namespace Database\Factories;

use App\Enums\QrRenderFormat;
use App\Models\QrCode;
use App\Models\QrCodeRender;
use Illuminate\Database\Eloquent\Factories\Factory;

/**
 * @extends Factory<QrCodeRender>
 */
class QrCodeRenderFactory extends Factory
{
    /**
     * Define the model's default state.
     *
     * @return array<string, mixed>
     */
    public function definition(): array
    {
        return [
            'qr_code_id' => QrCode::factory(),
            'format' => fake()->randomElement(QrRenderFormat::cases()),
            'ip_address' => fake()->ipv4(),
        ];
    }

    /**
     * Indicate that the code was rendered as a PNG.
     */
    public function png(): static
    {
        return $this->state(fn (array $attributes) => [
            'format' => QrRenderFormat::Png,
        ]);
    }

    /**
     * Indicate that the code was rendered as an SVG.
     */
    public function svg(): static
    {
        return $this->state(fn (array $attributes) => [
            'format' => QrRenderFormat::Svg,
        ]);
    }
}
