<?php

namespace Database\Seeders;

use App\Enums\RoleEnum;
use App\Models\Journalist;
use App\Models\PartnerMedia;
use Illuminate\Database\Seeder;

class CompanySeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        PartnerMedia::factory()
            ->count(3)
            ->create()
            ->each(function ($media) {
                // Assign role to the user associated with the company
                $media->company->user->assignRole(RoleEnum::PERUSAHAAN);

                // Create journalists for the media
                Journalist::factory()
                    ->count(random_int(1, 3))
                    ->create(['partner_media_id' => $media->id]);
            });
    }
}
