<?php

namespace Database\Factories;

use App\Models\Feed;
use App\Models\Keyword;
use App\Models\PlatformChannel;
use Illuminate\Database\Eloquent\Factories\Factory;

class KeywordFactory extends Factory
{
    protected $model = Keyword::class;

    public function definition(): array
    {
        return [
            'feed_id' => Feed::factory(),
            'platform_channel_id' => PlatformChannel::factory(),
            'keyword' => $this->faker->word(),
            'is_active' => $this->faker->boolean(70), // 70% chance of being active
            'created_at' => $this->faker->dateTimeBetween('-1 year', 'now'),
            'updated_at' => now(),
        ];
    }

    public function forFeed(Feed $feed): static
    {
        return $this->state(fn (array $attributes) => [
            'feed_id' => $feed->id,
        ]);
    }

    public function forChannel(PlatformChannel $channel): static
    {
        return $this->state(fn (array $attributes) => [
            'platform_channel_id' => $channel->id,
        ]);
    }

    public function active(): static
    {
        return $this->state(fn (array $attributes) => [
            'is_active' => true,
        ]);
    }

    public function inactive(): static
    {
        return $this->state(fn (array $attributes) => [
            'is_active' => false,
        ]);
    }
}
