<?php

namespace Database\Factories;

use App\Models\Admin;
use App\Models\Report;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;

/** @extends Factory<Report> */
class ReportFactory extends Factory
{
    protected $model = Report::class;

    public function definition(): array
    {
        return [
            'uuid' => (string) Str::uuid(),
            'report_name' => fake()->sentence(3),
            'report_type' => fake()->randomElement(['executive', 'security', 'financial', 'tracking']),
            'module' => fake()->randomElement(['users', 'devices', 'security', 'finance']),
            'filters' => ['date_range' => 'last_30_days'],
            'generated_by' => Admin::factory(),
            'format' => 'pdf',
            'status' => 'queued',
            'progress' => 0,
            'expires_at' => now()->addDays(7),
        ];
    }

    public function completed(): static
    {
        return $this->state(fn (): array => [
            'disk' => 'local',
            'file_path' => 'reports/example.pdf',
            'checksum' => hash('sha256', 'example-report'),
            'file_size' => 1024,
            'status' => 'completed',
            'progress' => 100,
            'started_at' => now()->subMinute(),
            'completed_at' => now(),
            'generated_at' => now(),
        ]);
    }
}
