<?php

namespace Database\Seeders;

use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use App\Models\Master\Menu;

class MenuSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        $menu = [
            [
                'parent_id'     => '0',
                'title'         => 'Master Data',
                'module'        => 'modules.master.*',
                'url'           => '#',
                'menu_type'     => 'sidebar',
                'menu_icon'     => 'ri-database-2-line',
                'ordering'      =>	'5',
                'status'        => 'true',
                'created_by'    => '1',
                'updated_by'    => '0'
            ],[
                'parent_id'     => '0',
                'title'         => 'User & Hak Akses',
                'module'        => 'modules.management.*',
                'url'           => '#',
                'menu_type'     => 'sidebar',
                'menu_icon'     => 'ri-database-2-line', 
                'ordering'      =>	'5',
                'status'        => 'true',
                'created_by'    => '1',
                'updated_by'    => '0'
            ],[
                'parent_id'      => '2',
                'title'          => 'Data Users',
                'module'         => 'modules.management.user.*',
                'url'            => 'management/user',
                'menu_type'      => 'sidebar',
                'menu_icon'      => 'ri-user-line', 
                'ordering'       => '1',
                'status'         => 'true',
                'created_by'     => '1',
                'updated_by'     => '0'
            ],[
                'parent_id'      => '2',
                'title'          => 'Data Role User',
                'module'         => 'modules.management.role.*',
                'url'           => 'management/role',
                'menu_type'      => 'sidebar',
                'menu_icon'      => 'ri-share-line', 
                'ordering'       =>	'3',
                'status'         => 'true',
                'created_by'     => '1',
                'updated_by'     => '0'
            ],[
                'parent_id'      => '1',
                'title'          => 'Data Instansi',
                'module'         => 'modules.instansi.*',
                'url'           => 'master/instansi',
                'menu_type'      => 'sidebar',
                'menu_icon'      => 'ri-home-line', 
                'ordering'       =>'1',
                'status'         => 'true',
                'created_by'     => '1',
                'updated_by'     => '0'
            ],[
                'parent_id'      => '0',
                'title'          => 'Open Data',
                'module'         => 'modules.opendata.*',
                'url'           => '#',
                'menu_type'      => 'sidebar',
                'menu_icon'      => 'ri-database-2-line', 
                'ordering'       =>	'1',
                'status'         => 'true',
                'created_by'     => '1',
                'updated_by'     => '0'
            ],[
                'parent_id'      => '6',
                'title'          => 'Dataset',
                'module'         => 'modules.opendata.dataset.*',
                'url'            => 'opendata/dataset',
                'menu_type'      => 'sidebar',
                'menu_icon'      => 'ri-database-2-line', 
                'ordering'       =>	'1',
                'status'         => 'true',
                'created_by'     => '1',
                'updated_by'     => '0'
            ],
        ];

        foreach($menu as $dataMenu){
            Menu::updateOrCreate([
                'parent_id'      => $dataMenu['parent_id'],
                'title'          => $dataMenu['title'],
                'module'         => $dataMenu['module'],
                'url'            => $dataMenu['url'],
                'menu_type'      => $dataMenu['menu_type'],
                'menu_icon'      => $dataMenu['menu_icon'],
                'ordering'       =>	$dataMenu['ordering'],
                'status'         => $dataMenu['status'],
                'created_by'     => $dataMenu['created_by'],
                'updated_by'     => $dataMenu['updated_by'],
            ],[
                'parent_id'      => $dataMenu['parent_id'],
                'title'          => $dataMenu['title'],
                'module'         => $dataMenu['module'],
                'url'            => $dataMenu['url'],
                'menu_type'      => $dataMenu['menu_type'],
                'menu_icon'      => $dataMenu['menu_icon'],
                'ordering'       =>	$dataMenu['ordering'],
                'status'         => $dataMenu['status'],
                'created_by'     => $dataMenu['created_by'],
                'updated_by'     => $dataMenu['updated_by'],
            ]);
        }
    }
}
