<?php

namespace Database\Seeders;

use App\Enums\ApprovalStatus;
use App\Enums\CooperationStatus;
use App\Models\Cooperation;
use App\Models\PartnerMedia;
use Illuminate\Database\Seeder;

class CooperationSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        $cooperation = Cooperation::create([
            'title' => 'Kerja Sama Media '.now()->format('Y'),
            'description' => 'Kerja sama media untuk penyebarluasan informasi publik.',
            'initial_submission_date' => now()->subDay(),
            'final_submission_date' => now()->addDay(),
            'status' => CooperationStatus::PENDING,
        ]);

        $verifiedMedia = PartnerMedia::verified()->get();

        foreach ($verifiedMedia as $media) {
            $cooperation->partnerMedia()->attach($media->id, [
                'status' => ApprovalStatus::PENDING,
                'created_at' => now(),
                'updated_at' => now(),
            ]);
        }
    }
}
