<?php

namespace Database\Seeders;

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

class PageSeeder extends Seeder
{
    public function run(): void
    {
        $data = json_decode(
            file_get_contents(__DIR__ . '/data/pages.json'),
            true
        );

        foreach ($data as $page) {
            Page::updateOrCreate(
                ['slug' => $page['slug']],
                [
                    'title' => $page['title'],
                    'content' => $page['content'],
                    'is_published' => true,
                ]
            );
        }
    }
}
