<?php

namespace Database\Factories;

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

class GroupFactory extends Factory
{
    protected $model = Group::class;

    public function definition(): array
    {
        $name = $this->faker->unique()->company();

        return [
            'owner_user_id' => User::factory(),
            'name' => $name,
            'slug' => Str::slug($name),
            'headline' => $this->faker->sentence(6),
            'bio' => $this->faker->paragraph(),
            'visibility' => Group::VISIBILITY_PUBLIC,
            'status' => Group::LIFECYCLE_ACTIVE,
            'membership_policy' => Group::MEMBERSHIP_INVITE_ONLY,
            'website_url' => $this->faker->optional()->url(),
            'links_json' => [],
            'avatar_path' => null,
            'banner_path' => null,
            'artworks_count' => 0,
            'collections_count' => 0,
            'followers_count' => 0,
            'last_activity_at' => now(),
        ];
    }

    public function private(): self
    {
        return $this->state(fn (): array => [
            'visibility' => Group::VISIBILITY_PRIVATE,
        ]);
    }
}