<?php

namespace Database\Seeders;

use App\Models\Blog;
use App\Models\Category;
use App\Models\User;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;

class BlogSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        DB::table('posts')->truncate();
        $users = User::limit(4)->orderBy('id')->get();
        $types = Category::limit(5)->orderBy('id')->get();
        $blogs = [
            [
                'title' => 'How High-Performing Support Teams Reduce First Response Time',
                'details' => '<p>First response time improves when intake quality, routing rules, and queue ownership are clearly defined. This guide explains practical changes support teams can apply within one sprint.</p><p>Learn how to combine automation with human triage to reduce delays without sacrificing ticket quality.</p>',
            ],
            [
                'title' => 'Building an SLA Strategy That Actually Works',
                'details' => '<p>Many teams define SLA targets but struggle to maintain them consistently. In this article, we break down how to set realistic response and resolution targets by priority and business impact.</p><p>Includes a practical framework for breach-risk monitoring.</p>',
            ],
            [
                'title' => 'Ticket Triage Framework: From Chaos to Clarity',
                'details' => '<p>A structured triage process helps agents prioritize the right issues at the right time. We cover category design, ownership assignment, and escalation criteria used by mature support organizations.</p>',
            ],
            [
                'title' => 'What Good Support Documentation Looks Like',
                'details' => '<p>Strong documentation reduces repetitive tickets and improves resolution speed. This article outlines a repeatable format for writing knowledge-base articles that are easy to search and easy to follow.</p>',
            ],
            [
                'title' => 'Using Customer Feedback to Improve Support Operations',
                'details' => '<p>CSAT scores are useful only when tied to operational action. Learn how to review qualitative feedback, identify recurring friction points, and turn findings into process improvements.</p>',
            ],
            [
                'title' => 'When to Use Live Chat vs Ticketing',
                'details' => '<p>Support leaders often overuse one channel and underuse another. This guide explains how to route quick questions to chat and complex, traceable issues to ticket workflows for better outcomes.</p>',
            ],
            [
                'title' => 'Designing Support Workflows for Multi-Team Organizations',
                'details' => '<p>As organizations grow, support requests often span product, engineering, and operations. This article shows how to structure cross-team collaboration while preserving accountability and visibility.</p>',
            ],
            [
                'title' => 'Five Common Mistakes in Ticket Form Design',
                'details' => '<p>Poor forms create incomplete tickets and slow down triage. We review the most common form design issues and explain how to capture better context with fewer required fields.</p>',
            ],
            [
                'title' => 'How to Report Support Performance to Leadership',
                'details' => '<p>Executives need clear metrics tied to business impact. Learn which support KPIs to present monthly, how to explain trend changes, and how to align reporting with customer retention goals.</p>',
            ],
            [
                'title' => 'Operational Checklist for Launching a New Support Desk',
                'details' => '<p>Launching support without clear workflows creates avoidable backlog and customer frustration. This checklist covers categories, priorities, SLA definitions, escalation paths, and initial reporting setup.</p>',
            ],
        ];
        foreach ($blogs as $blog) {
            Blog::factory()->create([
                'title' => $blog['title'],
                'details' => $blog['details'],
                'type_id' => $types->random()->id,
                'author_id' => $users->random()->id,
            ]);
        }
    }
}
