<?php
namespace Database\Factories;

use App\Enums\CampaignStatus;
use App\Models\Campaign;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;

class CampaignFactory extends Factory
{
    protected $model = Campaign::class;

    public function definition(): array
    {
        $name = fake()->unique()->sentence(3);
        return [
            'name' => $name,
            'slug' => Str::slug($name),
            'objective' => fake()->paragraph(),
            'image' => null,
            'status' => CampaignStatus::Draft->value,
            'starts_at' => now(),
            'ends_at' => now()->addMonth(),
            'priority' => fake()->numberBetween(0, 10),
            'is_pinned' => false,
        ];
    }

    public function published(): static
    {
        return $this->state(fn(array $attr) => [
            'status' => CampaignStatus::Published->value,
            'starts_at' => now()->subDay(),
            'ends_at' => now()->addMonth(),
        ]);
    }
}
