<?php

namespace Database\Factories;

use App\Models\CatalogLandingPageClickout;
use App\Models\CatalogLandingPageVisit;
use App\Models\LandingPage;
use Illuminate\Database\Eloquent\Factories\Factory;

/**
 * @extends Factory<CatalogLandingPageClickout>
 */
class CatalogLandingPageClickoutFactory extends Factory
{
    protected $model = CatalogLandingPageClickout::class;

    /**
     * @return array<string, mixed>
     */
    public function definition(): array
    {
        return [
            'catalog_landing_page_visit_id' => CatalogLandingPageVisit::factory(),
            'landing_page_id' => LandingPage::factory(),
            'destination_url' => fake()->url(),
        ];
    }

    public function forVisit(CatalogLandingPageVisit $visit): static
    {
        return $this->state(fn (): array => [
            'catalog_landing_page_visit_id' => $visit->id,
            'landing_page_id' => $visit->landing_page_id,
        ]);
    }
}
