<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;

class SetorSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $setores = json_decode(file_get_contents(asset("json/secretarias.json")), true);
        $arrayInsert =[];

        foreach($setores as $setor){
            array_push($arrayInsert, ["id" => $setor['id'], "nome" => $setor['nome'], "sigla" => $setor['sigla'], "idSetorPai" => $setor['idSetorPai']]);
        }

        DB::table('setors')->insert($arrayInsert);
    }
}
