<?php

namespace Database\Seeders;

use App\Models\Post;
use Illuminate\Database\Seeder;

class PostSeeder extends Seeder
{
    public function run(): void
    {
        $posts = [
            [
                'title' => 'How to Make a Budget in 5 Easy Steps',
                'slug' => 'how-to-make-a-budget-in-5-easy-steps',
                'category' => 'Budgeting',
                'cover_path' => 'images/blog/cover-2.jpg',
                'excerpt' => 'A budget isn\'t a punishment, it\'s permission. Here\'s how to build one you\'ll actually stick to, in five honest steps.',
                'body' => "A budget isn't a straightjacket. It's you, telling your money where to go, instead of wondering where it went.\n\n**Step 1: Know your real income.** Not your gross salary, what actually lands. Include side hustles, but only the consistent part.\n\n**Step 2: Track one month, honestly.** Before changing anything, just watch. Go through M-Pesa and bank statements. Most people find 10-15% of spending they can't explain, that's not failure, that's information.\n\n**Step 3: Give every shilling an assignment.** Essentials (rent, food, transport, fees), then future-you (savings, debt payoff, investments), then life (family support, church, fun, yes, fun gets a line).\n\n**Step 4: Automate the important parts.** Savings should leave your account the day money arrives. What you don't see, you don't spend.\n\n**Step 5: Review monthly, adjust without guilt.** A budget that survived contact with reality and got adjusted is a working budget. One that got abandoned in week two was just a wish list.\n\nReady to make yours? Our interactive Budget Builder does the math while you drag the sliders.",
                'published_at' => now()->subDays(10),
            ],
            [
                'title' => 'How to Get Out of Debt, and Stay Out',
                'slug' => 'how-to-get-out-of-debt',
                'category' => 'Debt',
                'cover_path' => 'images/blog/cover-3.jpg',
                'excerpt' => 'Debt steals more than money, it steals peace. Here\'s the step-by-step way out, whether it\'s Fuliza, app loans or bank debt.',
                'body' => "Debt in Kenya is expensive, and mobile money has made borrowing so frictionless that many people are locked in a cycle of borrowing from one lender to pay another. Here's the way out.\n\n**First: face the number.** List every single debt, Fuliza, app loans, SACCO, bank, family. Amount, interest rate, minimum payment. Yes, it's uncomfortable. Naming the number takes away its power.\n\n**Second: stop the bleeding.** No new debt from today. If Fuliza is a monthly habit, the budget needs fixing first, a budget gap is the root, debt is the symptom.\n\n**Third: pick your strategy.** The *snowball* (smallest debt first, quick wins, motivation) or the *avalanche* (highest interest first, mathematically cheapest). Mobile loans are usually both the smallest AND most expensive, so in Kenya the two strategies often agree: kill the app loans first.\n\n**Fourth: protect the plan.** Build a small emergency buffer (even KES 5,000) at the same time, otherwise the next emergency sends you straight back to borrowing.\n\n**Fifth: celebrate milestones.** Every cleared loan is a victory. Mark it.\n\nOur free Debt Payoff Planner builds your personalised plan, and shows you your debt-free date.",
                'published_at' => now()->subDays(20),
            ],
            [
                'title' => 'The Top Frequently Asked Questions on Investing',
                'slug' => 'top-faqs-on-investing',
                'category' => 'Investing',
                'cover_path' => 'images/blog/cover-1.jpg',
                'excerpt' => '"Where do I even start?" "How much do I need?" "What about scams?", the questions we hear every single week, answered without jargon.',
                'body' => "**\"How much money do I need to start investing?\"**\nLess than you think. Money market funds in Kenya start from as little as KES 100-1,000. The amount matters far less than the habit.\n\n**\"Where should I put my money?\"**\nWrong first question, the right one is *what is the money for, and when will you need it?* Short-term goals (under 2 years) want safety: money market funds, treasury bills. Long-term goals (5+ years) can ride out ups and downs for growth: equities, bonds, real estate.\n\n**\"How do I avoid scams?\"**\nThree rules. If returns are 'guaranteed' and high, walk away. If you feel pressure to act *now* before the window closes, walk away faster. If you can't explain how the money is made, it's not an investment, it's a gamble.\n\n**\"Should I pay off debt or invest first?\"**\nExpensive debt (mobile loans, credit cards) first, always, no investment reliably beats those interest rates. Cheap debt (a reasonable mortgage) can coexist with investing.\n\n**\"What if I don't understand finance?\"**\nThat's not a disqualification, it's the starting line. Everything we build at Money-Wise is jargon-free by design. Start with the free Financial Health Check and we'll show you your next step.",
                'published_at' => now()->subDays(30),
            ],
        ];

        $more = [
            [
                'title' => 'Building Financial Resilience When Everything Costs More',
                'slug' => 'building-financial-resilience',
                'category' => 'Saving',
                'cover_path' => 'images/stock/market-vendor.jpg',
                'excerpt' => 'Prices rise, incomes lag. Resilience isn\'t about earning more, it\'s about building a money system that bends without breaking.',
                'body' => "Resilience is not a savings balance, it's a system with shock absorbers.\n\n**Absorber 1: the buffer.** One month of essential expenses, parked where you can reach it in days. This single cushion converts most emergencies into inconveniences.\n\n**Absorber 2: the flexible budget.** Know your survival number, the bare minimum month. When shocks come, you switch to it without drama, because you've already defined it.\n\n**Absorber 3: multiple taps.** A side income, however small, changes the maths of a job loss completely. One client who braided hair on weekends survived a six-month job gap without borrowing a coin.\n\n**Absorber 4: insurance before you need it.** Health cover is the difference between a hospital bill and a financial catastrophe.\n\nStart with absorber 1 this month. The Emergency Fund calculator sizes it in 90 seconds.",
                'published_at' => now()->subDays(45),
            ],
            [
                'title' => 'Help! My Partner and I Can\'t Agree About Money',
                'slug' => 'partners-money-conflict',
                'category' => 'Family',
                'cover_path' => 'images/stock/budget-table.jpg',
                'excerpt' => 'Money fights are rarely about money. Here\'s how couples move from blame to a shared plan, without a single spreadsheet ambush.',
                'body' => "Most money fights are values fights wearing money's clothes. The saver isn't stingy, they value security. The spender isn't reckless, they value joy and connection. Until you see the value behind the behaviour, you'll keep fighting the behaviour.\n\n**Step 1: take the personality test, both of you.** Two Money Personality results side by side turn 'you always…' into 'oh, that's why you…'. The conversation changes instantly.\n\n**Step 2: agree on the non-negotiables.** Rent, fees, the emergency fund. These get funded first, automatically, before either of you touches the rest.\n\n**Step 3: personal money, no questions asked.** Each partner gets an agreed amount monthly that the other never audits. Most conflict dies right here.\n\n**Step 4: a monthly money date.** Thirty minutes, no phones, no blame. Review the plan, not each other.\n\nShared values, separate personalities, one plan. That's the formula.",
                'published_at' => now()->subDays(60),
            ],
            [
                'title' => 'Investing Through Life\'s Seasons: 20s, 30s, 40s and Beyond',
                'slug' => 'investing-through-life-seasons',
                'category' => 'Investing',
                'cover_path' => 'images/stock/retired-couple.jpg',
                'excerpt' => 'The right investment at 25 can be the wrong one at 45. A field guide to investing by life stage.',
                'body' => "**Your 20s: buy habits, not assets.** Your biggest asset is time. Automate any amount into a money market fund, learn the vocabulary, make your mistakes small. A modest monthly amount started at 23 beats a large one started at 35, compounding is rude like that.\n\n**Your 30s: buy growth.** Income rises, responsibilities rise faster. Fight lifestyle inflation by automating raises into investments before you feel them. This is the decade for equities, education funds that mature with your children, and the home deposit plan.\n\n**Your 40s: buy balance.** Peak earning years. Max out retirement vehicles, diversify across asset classes, and across borders if you can. Start shifting some growth assets toward income-generating ones.\n\n**50s and beyond: buy certainty.** Capital preservation beats growth chasing. Bonds, income funds, paid-off property. The question changes from 'how much can this grow?' to 'how reliably does this pay?'\n\nWhatever your season: the Wealth & Goals planner puts your numbers on your timeline.",
                'published_at' => now()->subDays(75),
            ],
            [
                'title' => 'Six Money Habits That Quietly Build Wealth',
                'slug' => 'six-money-habits',
                'category' => 'Budgeting',
                'cover_path' => 'images/stock/mother-child.jpg',
                'excerpt' => 'No hacks, no hustle-porn, six boring, compounding habits that separate builders from spenders.',
                'body' => "**1. Pay yourself first.** Savings leave your account the day money arrives, before the world starts asking. What you don't see, you don't spend.\n\n**2. Track weekly, not daily.** Daily tracking burns out; monthly tracking forgets. A ten-minute Sunday review is the sustainable rhythm.\n\n**3. The 48-hour rule.** Any unplanned purchase above a set amount waits 48 hours. Half the urge evaporates; what survives was probably worth it.\n\n**4. Automate the boring.** Standing orders for savings, investments and bills. Willpower is for emergencies, not infrastructure.\n\n**5. One in, one out for subscriptions.** New streaming service? Something else gets cancelled. Subscriptions are where budgets go to leak.\n\n**6. An annual money day.** Once a year: review insurance, renegotiate bills, rebalance investments, update the will. One day that pays for the other 364.\n\nPick ONE habit. Run it for 30 days. Then add the next, compounding works on habits too.",
                'published_at' => now()->subDays(90),
            ],
        ];

        foreach (array_merge($posts, $more) as $post) {
            Post::updateOrCreate(['slug' => $post['slug']], $post);
        }
    }
}
