<?php
namespace Database\Seeders;

use App\Models\EmailTemplate;
use App\Models\User;
use Illuminate\Database\Seeder;

class EmailTemplateDemoSeeder extends Seeder
{
    public function run(): void
    {
        $owner = User::whereNotNull('business_id')->orderByDesc('is_admin')->firstOrFail();
        $categories = ['Sales', 'Marketing', 'Follow-up', 'Support', 'Onboarding'];
        for ($i = 1; $i <= 50; $i++) EmailTemplate::updateOrCreate(
            ['name' => sprintf('QA Template 50-%03d', $i)],
            ['subject' => sprintf('QA email template subject %03d', $i), 'body' => "Hello {{contact_name}}, this is QA email template {$i}.",
             'category' => $categories[($i - 1) % count($categories)], 'active' => $i % 5 !== 0,
             'owner_id' => $owner->id, 'business_id' => $owner->business_id]
        );
    }
}
