<?php

namespace Database\Factories;

use App\Models\Article;
use App\Models\ArticlePublication;
use App\Models\PlatformChannel;
use Illuminate\Database\Eloquent\Factories\Factory;

class ArticlePublicationFactory extends Factory
{
    protected $model = ArticlePublication::class;

    public function definition(): array
    {
        return [
            'article_id' => Article::factory(),
            'platform_channel_id' => PlatformChannel::factory(),
            'post_id' => $this->faker->uuid(),
            'platform' => 'lemmy',
            'published_at' => $this->faker->dateTimeBetween('-1 month', 'now'),
            'published_by' => $this->faker->userName(),
            'publication_data' => null,
            'created_at' => $this->faker->dateTimeBetween('-1 month', 'now'),
            'updated_at' => now(),
        ];
    }

    public function recentlyPublished(): static
    {
        return $this->state(fn (array $attributes) => [
            'published_at' => $this->faker->dateTimeBetween('-1 day', 'now'),
        ]);
    }
}
