<?php

declare(strict_types=1);

namespace Database\Factories;

use App\Models\Workspace;
use App\Models\WorkspaceSubscription;
use Illuminate\Database\Eloquent\Factories\Factory;

/**
 * @extends Factory<WorkspaceSubscription>
 */
class WorkspaceSubscriptionFactory extends Factory
{
    protected $model = WorkspaceSubscription::class;

    /**
     * @return array<string, mixed>
     */
    public function definition(): array
    {
        $periodStartsAt = now()->subDays(1)->startOfMinute();

        return [
            'workspace_id' => Workspace::factory(),
            'state' => WorkspaceSubscription::STATE_ACTIVE,
            'billing_reference' => 'sub_'.fake()->bothify('????##'),
            'trial_ends_at' => null,
            'current_period_starts_at' => $periodStartsAt,
            'current_period_ends_at' => $periodStartsAt->copy()->addDays(30),
            'status_reason' => 'Subscription is current.',
        ];
    }
}