<?php

namespace Database\Factories;

use App\Domains\Subscription\Models\Plan;
use App\Domains\Workspace\Models\Workspace;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;

class WorkspaceFactory extends Factory
{
    protected $model = Workspace::class;

    public function definition(): array
    {
        return [
            'name'     => fake()->company(),
            'slug'     => Str::slug(fake()->unique()->words(3, true)),
            'owner_id' => User::factory(),
        ];
    }

    public function free(): static
    {
        return $this->state(fn () => [
            'plan_id' => Plan::factory()->free()->create()->id,
        ]);
    }

    public function pro(): static
    {
        return $this->state(fn () => [
            'plan_id'        => Plan::factory()->pro()->create()->id,
            'subdomain_full' => null,
        ]);
    }
}
