<?php

namespace Database\Seeders;

use App\Models\Article;
use App\Models\Project;
use App\Models\User;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;

class DatabaseSeeder extends Seeder
{
    use WithoutModelEvents;

    public function run(): void
    {
        // Content author / administrator account for the CMS.
        User::firstOrCreate(
            ['email' => 'admin@brokaminternational.com'],
            ['name' => 'Brokam Administrator', 'password' => bcrypt('password')]
        );

        $this->seedProjects();
        $this->seedArticles();
    }

    private function seedProjects(): void
    {
        $projects = [
            [
                'slug' => 'national-broadcaster-studio-upgrade',
                'title' => 'National Broadcaster Studio Upgrade',
                'client' => 'Regional Broadcast Network',
                'industry' => 'broadcast-media',
                'service' => 'broadcast-av',
                'location' => 'East Africa',
                'year' => 2025,
                'featured' => true,
                'summary' => 'A full studio and production refit — cameras, signal processing, audio reinforcement, and control — sourced and integrated under a single contract.',
                'services' => ['broadcast-av', 'system-integration', 'procurement'],
                'outcomes' => [
                    'Two production studios re-equipped with zero broadcast downtime',
                    'End-to-end signal chain commissioned and documented',
                    'Operator training delivered ahead of go-live',
                ],
                'body' => "The broadcaster needed to modernise ageing studio infrastructure without interrupting its on-air schedule. Brokam led the specification, sourced production equipment from trusted global manufacturers, managed importation and customs, and integrated the complete signal chain.\n\nWork was phased so each studio came online while the other continued broadcasting. We commissioned, tested, and documented every system before a structured handover and operator training.",
            ],
            [
                'slug' => 'enterprise-data-centre-buildout',
                'title' => 'Enterprise Data Centre Build-out',
                'client' => 'Financial Services Group',
                'industry' => 'finance',
                'service' => 'ict-infrastructure',
                'location' => 'Nairobi, Kenya',
                'year' => 2025,
                'featured' => true,
                'summary' => 'Structured cabling, network fabric, and resilient power for a new high-availability data centre supporting core banking systems.',
                'services' => ['ict-infrastructure', 'power-solutions', 'system-integration'],
                'outcomes' => [
                    'N+1 power and cooling resilience delivered',
                    'Structured cabling certified to performance standards',
                    'Redundant network fabric with no single point of failure',
                ],
                'body' => "A financial services group required a new data centre engineered for continuous availability. Brokam delivered the structured cabling, active and passive network equipment, and a resilient power architecture with UPS and backup.\n\nEvery subsystem was integrated and tested as one environment, with full documentation handed over for the client's operations team.",
            ],
            [
                'slug' => 'campus-wide-security-deployment',
                'title' => 'Campus-Wide Security Deployment',
                'client' => 'University Campus',
                'industry' => 'education',
                'service' => 'security-systems',
                'location' => 'East Africa',
                'year' => 2024,
                'featured' => true,
                'summary' => 'Integrated CCTV, access control, and centralised monitoring across a multi-building campus.',
                'services' => ['security-systems', 'ict-infrastructure', 'system-integration'],
                'outcomes' => [
                    'Unified surveillance across all campus buildings',
                    'Role-based access control for staff and students',
                    'Single command-and-monitoring centre',
                ],
                'body' => "The institution needed a single, coherent security environment across a sprawling campus. Brokam supplied and integrated video surveillance, access control, and intrusion detection, all feeding a centralised command centre.\n\nThe networking backbone and security systems were delivered together, removing the complexity of coordinating multiple vendors.",
            ],
            [
                'slug' => 'solar-backup-power-rollout',
                'title' => 'Solar & Backup Power Rollout',
                'client' => 'Healthcare Network',
                'industry' => 'healthcare',
                'service' => 'power-solutions',
                'location' => 'Multiple sites',
                'year' => 2024,
                'featured' => false,
                'summary' => 'UPS, battery backup, and solar installations keeping critical healthcare systems powered through outages.',
                'services' => ['power-solutions', 'procurement'],
                'outcomes' => [
                    'Critical systems protected against grid outages',
                    'Long-term energy costs reduced with solar generation',
                    'Standardised power architecture across sites',
                ],
                'body' => "A healthcare network could not tolerate downtime in critical systems. Brokam designed and installed uninterruptible power supplies, battery backup, and solar generation across multiple sites.\n\nThe rollout standardised the power architecture, improving resilience while reducing long-term energy costs.",
            ],
            [
                'slug' => 'corporate-av-and-conferencing',
                'title' => 'Corporate AV & Conferencing Refresh',
                'client' => 'Multinational Enterprise',
                'industry' => 'enterprise',
                'service' => 'broadcast-av',
                'location' => 'Regional HQ',
                'year' => 2024,
                'featured' => false,
                'summary' => 'Conferencing, presentation, and digital signage systems delivered across a corporate headquarters.',
                'services' => ['broadcast-av', 'system-integration'],
                'outcomes' => [
                    'Consistent conferencing experience across meeting spaces',
                    'Centralised AV control and digital signage',
                    'Simplified support through standardisation',
                ],
                'body' => "An enterprise client wanted a consistent, reliable AV experience across its headquarters. Brokam supplied and integrated conferencing, presentation, and digital signage systems, with centralised control and a standardised design that simplified ongoing support.",
            ],
            [
                'slug' => 'government-network-modernisation',
                'title' => 'Government Network Modernisation',
                'client' => 'Public Sector Agency',
                'industry' => 'government',
                'service' => 'ict-infrastructure',
                'location' => 'East Africa',
                'year' => 2023,
                'featured' => false,
                'summary' => 'Procurement and deployment of a modern, resilient network for a public-sector agency.',
                'services' => ['ict-infrastructure', 'procurement', 'system-integration'],
                'outcomes' => [
                    'Accountable single-vendor delivery',
                    'Modern switching, routing, and wireless coverage',
                    'Full documentation for in-house operations',
                ],
                'body' => "A public-sector agency needed to modernise its network with full accountability and supply assurance. Brokam managed sourcing, importation, and integration end to end, delivering modern switching, routing, and wireless coverage with complete documentation.",
            ],
        ];

        foreach ($projects as $p) {
            Project::updateOrCreate(['slug' => $p['slug']], $p);
        }
    }

    private function seedArticles(): void
    {
        $articles = [
            [
                'slug' => 'why-single-accountable-partner-matters',
                'title' => 'Why a Single Accountable Partner De-risks Infrastructure Projects',
                'category' => 'Insight',
                'author' => 'Brokam International',
                'published_at' => '2026-06-10',
                'featured' => true,
                'excerpt' => 'Coordinating sourcing, logistics, installation, and integration across many vendors multiplies risk. Consolidating accountability changes the outcome.',
                'body' => "When a technology infrastructure project depends on dozens of suppliers, every handover is a point where schedule, cost, and quality can slip. The more vendors involved, the more interfaces there are to manage — and the harder it becomes to hold anyone accountable for the final result.\n\n## One contract, one outcome\n\nBrokam consolidates specification, sourcing, importation, logistics, installation, and integration under a single contract. Clients get one point of contact and one party accountable for a system that simply works.\n\n## Less complexity, more certainty\n\nA single accountable partner removes the coordination overhead, compresses timelines, and gives clients supply assurance backed by a global network of manufacturers and distributors.",
            ],
            [
                'slug' => 'building-resilient-power-for-critical-systems',
                'title' => 'Building Resilient Power for Critical Systems',
                'category' => 'Insight',
                'author' => 'Brokam International',
                'published_at' => '2026-05-28',
                'featured' => false,
                'excerpt' => 'From UPS and battery backup to solar generation, resilient power keeps infrastructure running and reduces long-term cost.',
                'body' => "Downtime in critical systems is expensive and, in some sectors, dangerous. Resilient power design protects against grid instability while controlling long-term energy spend.\n\n## A layered approach\n\nUninterruptible power supplies and battery backup bridge short outages; standby generation and solar reduce dependence on the grid. Designed together, they keep infrastructure online through disruption.\n\n## Planned for the long term\n\nBrokam specifies power architectures sized to the load and the risk profile, then supplies, installs, and supports them as part of an integrated environment.",
            ],
            [
                'slug' => 'global-sourcing-supply-assurance',
                'title' => 'Global Sourcing and the Case for Supply Assurance',
                'category' => 'News',
                'author' => 'Brokam International',
                'published_at' => '2026-05-12',
                'featured' => false,
                'excerpt' => 'A trusted global supply network gives clients competitive pricing and the certainty that the right products arrive on time, on budget, and in full.',
                'body' => "Supply chains for technology infrastructure span continents. Without trusted relationships and logistics expertise, projects stall waiting for equipment.\n\n## The Brokam network\n\nWe source from a global network of trusted manufacturers and distributors, then manage freight, importation, customs clearance, and last-mile delivery.\n\n## On time, on budget, in full\n\nScale and relationships translate into competitive pricing and supply assurance — a single point of accountability for the entire supply chain.",
            ],
            [
                'slug' => 'integrating-broadcast-ict-security-power',
                'title' => 'Integrating Broadcast, ICT, Security, and Power as One Environment',
                'category' => 'Insight',
                'author' => 'Brokam International',
                'published_at' => '2026-04-30',
                'featured' => false,
                'excerpt' => 'Complete solutions, not disconnected components: how system integration turns separate subsystems into one coherent environment.',
                'body' => "Buying boxes is easy; making them work together is hard. System integration is where infrastructure projects succeed or fail.\n\n## Designed to interoperate\n\nBrokam unifies broadcast, ICT, security, and power into a single environment — designed, configured, tested, and commissioned as one.\n\n## Delivered and supported\n\nWe document everything, train the client's team, and provide ongoing support, so the integrated system performs over its full life.",
            ],
        ];

        foreach ($articles as $a) {
            Article::updateOrCreate(['slug' => $a['slug']], $a);
        }
    }
}
