<?php

namespace Database\Seeders;

use App\Models\Usuario;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;

class CargosSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        DB::table('cargos')->whereNotIn('nombre', array_values(Usuario::ROLE_LABELS))->delete();

        foreach (Usuario::cargoOptions() as $cargo) {
            DB::table('cargos')->updateOrInsert(
                ['nombre' => (string) $cargo],
                ['updated_at' => now(), 'created_at' => now()]
            );
        }
    }
}
