<?php

namespace Database\Seeders;

// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use App\Models\User;
use App\Models\Master\MasterTingkatSekolah;
use App\Models\Master\MasterGroup;
use App\Models\Master\MasterGroupUser;
use Hash;

class DatabaseSeeder extends Seeder
{
    /**
     * Seed the application's database.
     */
    public function run(): void
    {
        $data = [
            ['name' => 'SD'],
            ['name' => 'SMP'],
            ['name' => 'SMA'],
            ['name' => 'SMK'],
            ['name' => 'MI'],
            ['name' => 'MTs'],
            ['name' => 'MA'],
            ['name' => 'SD LB'],
            ['name' => 'SMP LB'],
            ['name' => 'SMA LM'],
            ['name' => 'SLB Khusus'],
        ];

        foreach($data as $val){
            MasterTingkatSekolah::updateOrCreate([
                'name' => $val['name'],
            ],[
                'name' => $val['name'],
            ]);
        }


        $group = [
            ['name' => 'Administrator','alias' => 'administrator'],
            ['name' => 'Sekolah','alias'=> 'sekolah'],
            ['name' => 'Satuan Pelaksana','alias' => 'satuan_pelaksana'],
            ['name' => 'Suku Dinas', 'alias' => 'suku_dinas'],
            ['name' => 'Dinas','alias' => 'dinas'],
            ['name' => 'Penilai Kota','alias' => 'penilai_kota'],
            ['name' => 'Penilai Provinsi','alias' => 'penilai_provinsi'],
        ];

        foreach($group as $valGroup){
            MasterGroup::updateOrCreate([
                'name' => $valGroup['name'],
                'alias' => $valGroup['alias'],
            ],[
                'name' => $valGroup['name'],
                'alias' => $valGroup['alias'],
                'status' => 1,
            ]);
        }

        User::updateOrCreate([
            'name' => 'Administrator',
            'username' => 'administrator',
            'email' => 'adminadiwiyata@dlh.go.id',
        ],[
            'name' => 'Administrator',
            'username' => 'administrator',
            'email' => 'adminadiwiyata@dlh.go.id',
            'ms_group_id' => '1',
            'password' => Hash::make('##SekolahAdiwiyata123'),
        ]);

        MasterGroupUser::updateOrCreate([
            'ms_group_id' => '1',
            'user_id' => '1',
        ],[
            'ms_group_id' => '1',
            'user_id' => '1',
        ]);


        
    }
}
