<?php

use yii\db\Migration;

class m260430_000002_create_site_content_table extends Migration
{
    public function safeUp(): void
    {
        $this->createTable('{{%site_content}}', [
            'id'            => $this->primaryKey()->unsigned(),
            'content_key'   => $this->string(100)->notNull()->unique(),
            'content_value' => $this->text()->null(),
            'label'         => $this->string(200)->notNull()->defaultValue(''),
            'section'       => $this->string(60)->notNull()->defaultValue('general'),
            'updated_at'    => $this->integer()->unsigned()->notNull(),
        ], 'ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci');

        $now = time();
        $rows = [
            // ── Hero ──────────────────────────────────────────
            ['hero_badge',        'Certified Nutritionist · 10+ Years Experience',
             'Hero — Badge Text',                          'hero'],
            ['hero_heading',      "Fuel Your Body.",
             'Hero — Main Heading',                        'hero'],
            ['hero_highlight',    "Elevate Your\nPerformance.",
             'Hero — Highlighted (italic) Heading',        'hero'],
            ['hero_subtext',
             'Science-backed, personalised nutrition for elite athletes and everyday wellness seekers. Trusted by India Women\'s Cricket, National champions, and 200+ athletes across 8+ sports.',
             'Hero — Sub-paragraph',                       'hero'],

            // ── About ─────────────────────────────────────────
            ['about_bio_1',
             'I\'m Susan Jacob, a Certified Nutritionist, Sports Nutritionist, and Nutrigenomics Expert with over 10 years of experience. I lead SJ Nutrizione, helping individuals and athletes achieve sustainable health and peak performance through personalised, science-based nutrition.',
             'About — Bio Paragraph 1',                    'about'],
            ['about_bio_2',
             'My approach is rooted in evidence-based practice — I don\'t believe in quick fixes or one-size-fits-all plans. Every client receives a deeply personalised strategy that considers their body, lifestyle, goals, and cultural background.',
             'About — Bio Paragraph 2',                    'about'],
            ['about_philosophy',
             'Nutrition is not about restriction — it\'s about nourishment. The right food, at the right time, for the right body, transforms not just your health but your entire life.',
             'About — Philosophy Quote',                   'about'],

            // ── Site Settings ─────────────────────────────────
            ['contact_phone',     '+91 84209 60825',
             'Settings — Phone Number',                    'settings'],
            ['contact_email',     'sj.nutrizione@gmail.com',
             'Settings — Email Address',                   'settings'],
            ['contact_hours',     'Mon – Sat, 11 AM – 6 PM',
             'Settings — Consultation Hours',              'settings'],
            ['whatsapp_number',   '918420960825',
             'Settings — WhatsApp Number (with country code, no +)',  'settings'],
            ['instagram_handle',  'sj_nutrizione',
             'Settings — Instagram Handle (without @)',    'settings'],
        ];

        foreach ($rows as $r) {
            $this->insert('{{%site_content}}', [
                'content_key'   => $r[0],
                'content_value' => $r[1],
                'label'         => $r[2],
                'section'       => $r[3],
                'updated_at'    => $now,
            ]);
        }
    }

    public function safeDown(): void
    {
        $this->dropTable('{{%site_content}}');
    }
}
