<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use App\Models\Announcement;
use App\Services\DummyDataService;

class AnnouncementSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        $announcements = DummyDataService::getPengumuman();

        foreach ($announcements as $data) {
            $adminId = \App\Models\User::where('role', 'penjaga perpus')->first()?->id ?? 2;

            Announcement::updateOrCreate(
                ['id' => $data['id']],
                [
                    'user_id' => $adminId,
                    'type' => $data['type'],
                    'icon' => $data['icon'],
                    'title' => $data['title'],
                    'content' => $data['content'],
                ]
            );
        }
    }
}
