<?php
namespace Database\Factories;

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

class ArtworkFactory extends Factory
{
    protected $model = Artwork::class;

    public function definition(): array
    {
        $title = $this->faker->unique()->sentence(3);

        return [
            'user_id' => User::factory(),
            'title' => $title,
            'slug' => Str::slug($title) . '-' . $this->faker->unique()->randomNumber(5),
            'description' => $this->faker->paragraph(),
            'file_name' => 'image.jpg',
            'file_path' => 'uploads/artworks/image.jpg',
            'file_size' => 12345,
            'mime_type' => 'image/jpeg',
            'width' => 800,
            'height' => 600,
            'is_public' => true,
            'is_approved' => true,
            'published_at' => now()->subDay(),
        ];
    }

    public function unpublished(): self
    {
        return $this->state(fn () => ['published_at' => null]);
    }

    public function private(): self
    {
        return $this->state(fn () => ['is_public' => false]);
    }

    public function unapproved(): self
    {
        return $this->state(fn () => ['is_approved' => false]);
    }
}
