<?php

namespace Database\Factories;

use App\Models\Song;
use Illuminate\Database\Eloquent\Factories\Factory;

class SongFactory extends Factory
{
    protected $model = Song::class;

    public function definition(): array
    {
        return [
            'ccli_id' => $this->faker->boolean(80) ? $this->faker->unique()->numerify('######') : null,
            'title' => $this->faker->sentence(3),
            'author' => $this->faker->name(),
            'copyright_text' => $this->faker->optional()->sentence(),
            'copyright_year' => (string) $this->faker->year(),
            'publisher' => $this->faker->optional()->company(),
            'has_translation' => $this->faker->boolean(25),
            'last_used_at' => $this->faker->optional()->dateTimeBetween('-6 months', 'now'),
        ];
    }

    public function fromCcli(): self
    {
        return $this->state(fn (): array => [
            'imported_from_ccli_at' => now(),
            'ccli_source_url' => 'https://songselect.ccli.com/Songs/9999001',
        ]);
    }
}
