<?php

namespace Database\Factories;

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

/**
 * @extends Factory<ReviewedWebsite>
 */
class ReviewedWebsiteFactory extends Factory
{
    protected $model = ReviewedWebsite::class;

    /**
     * @return array<string, mixed>
     */
    public function definition(): array
    {
        $name = fake()->company().' '.fake()->randomElement(['Shop', 'App', 'Exchange', 'Store']);

        return [
            'name' => $name,
            'slug' => Str::slug($name).'-'.Str::lower(Str::random(5)),
            'website_url' => 'https://'.Str::slug($name).'.example.test',
            'domain' => Str::slug($name).'.example.test',
            'industry' => ReviewedWebsite::INDUSTRY_GENERAL,
            'editorial_verdict' => fake()->randomElement([
                ReviewedWebsite::VERDICT_LEGIT,
                ReviewedWebsite::VERDICT_SCAM,
                ReviewedWebsite::VERDICT_MIXED,
                ReviewedWebsite::VERDICT_UNKNOWN,
            ]),
            'editorial_summary' => fake()->sentence(12),
            'editorial_content' => '<p>'.fake()->paragraphs(2, true).'</p>',
            'trust_score' => null,
            'trust_score_computed_at' => null,
            'manual_trust_score' => null,
            'approved_reviews_count' => 0,
            'status' => ReviewedWebsite::STATUS_DRAFT,
            'published_at' => null,
            'is_featured' => false,
            'featured_order' => 0,
        ];
    }

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