HEX
Server: LiteSpeed
System: Linux s1049.use1.mysecurecloudhost.com 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: xedaptot (3356)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: /home/xedaptot/ai.naniguide.com/database/factories/AdCreativeFactory.php
<?php

namespace Database\Factories;

use App\Model\AdCreative;
use App\Model\Customer;
use Illuminate\Database\Eloquent\Factories\Factory;

class AdCreativeFactory extends Factory
{
    protected $model = AdCreative::class;

    public function definition(): array
    {
        return [
            'uid' => uniqid(),
            'customer_id' => Customer::factory(),
            'name' => 'Test Creative ' . uniqid(),
            'type' => AdCreative::TYPE_IMAGE,
            'headline' => 'Test Headline',
            'primary_text' => 'This is ad body text for testing.',
            'description' => 'Short description of the ad creative.',
            'call_to_action' => 'learn_more',
            'destination_url' => 'https://example.com/landing',
        ];
    }

    public function image(): static
    {
        return $this->state(fn () => ['type' => AdCreative::TYPE_IMAGE]);
    }

    public function video(): static
    {
        return $this->state(fn () => ['type' => AdCreative::TYPE_VIDEO]);
    }

    public function carousel(): static
    {
        return $this->state(fn () => [
            'type' => AdCreative::TYPE_CAROUSEL,
            'carousel_cards' => [
                ['image' => 'https://example.com/1.jpg', 'headline' => 'Card 1', 'url' => 'https://example.com/1'],
                ['image' => 'https://example.com/2.jpg', 'headline' => 'Card 2', 'url' => 'https://example.com/2'],
            ],
        ]);
    }

    public function forCustomer(Customer $customer): static
    {
        return $this->state(fn () => ['customer_id' => $customer->id]);
    }

    /**
     * Attach a realistic BuilderJS PageElement with headline + text + image + CTA.
     */
    public function withBuilderContent(?array $content = null): static
    {
        return $this->state(fn () => [
            'builder_content' => $content ?? [
                'theme' => 'default',
                'name' => 'PageElement',
                'template' => 'Page',
                'page_title' => null,
                'blocks' => [
                    [
                        'name' => 'BlockElement',
                        'template' => 'Block',
                        'elements' => [
                            [
                                'name' => 'ImageElement',
                                'template' => 'Image',
                                'src' => 'https://images.unsplash.com/photo-1556742049-0cfed4f6a45d?w=1080&h=1080&fit=crop',
                                'alt' => '',
                                'formats' => ['width' => '100%'],
                                'effect' => [],
                            ],
                        ],
                        'formats' => [],
                    ],
                    [
                        'name' => 'BlockElement',
                        'template' => 'Block',
                        'elements' => [
                            [
                                'name' => 'HeadingElement',
                                'template' => 'Heading',
                                'type' => 'h2',
                                'text' => 'Test Headline',
                                'formats' => [],
                            ],
                            [
                                'name' => 'PElement',
                                'template' => 'P',
                                'text' => 'This is ad body text for testing.',
                                'formats' => [],
                            ],
                            [
                                'name' => 'ButtonElement',
                                'template' => 'Button',
                                'text' => 'Learn More',
                                'url' => 'https://example.com/landing',
                                'formats' => [],
                            ],
                        ],
                        'formats' => [],
                    ],
                ],
                'formats' => ['background_color' => '#FFFFFF'],
                'block_gap' => 0,
                'container_width' => 'narrow',
            ],
        ]);
    }
}