<?php

namespace App\Database\Seeds;

use App\Models\Configuracion\ConfigVariableModel;
use App\Models\Wiki\WikiSectionModel;
use App\Models\Wiki\WikiSectionRoleModel;
use CodeIgniter\Database\Seeder;

class WikiSectionSeeder extends Seeder
{
    protected array $dataAdmin = [
        [
            "name" =>  'Introducción',
            "slug" =>  'intro-admin',
            "icon" => 'ti ti-home-2',
            "roles" => [
                "admin",
            ],
        ],
        [
            "name" =>  'Presupuesto',
            "slug" =>  'presupuesto-admin',
            "icon" => 'ti ti-currency-dollar',
            "roles" => [
                "admin",
            ],
        ],
        [
            "name" =>  'Pedidos',
            "slug" =>  'pedidos-admin',
            "icon" => 'ti ti-file-description',
            "roles" => [
                "admin",
            ],

        ],
        [
            "name" =>  'Facturación',
            "slug" =>  'facturacion-admin',
            "icon" => 'ti ti-file-dollar',
            "roles" => [
                "admin",
            ],

        ],
        [
            "name" =>  'Logística',
            "slug" =>  'logistica-admin',
            "icon" => 'ti ti-truck',
            "roles" => [
                "admin",
            ],

        ],
        [
            "name" =>  'Tarifas',
            "slug" =>  'tarifas-admin',
            "icon" => 'ti ti-receipt',
            "roles" => [
                "admin",
            ],

        ],
        [
            "name" =>  'Configuración',
            "slug" =>  'config-admin',
            "icon" => 'ti ti-adjustments-horizontal',
            "roles" => [
                "admin",
            ],

        ],
        [
            "name" =>  'Mensajería',
            "slug" =>  'messages-admin',
            "icon" => 'ti ti-message',
            "roles" => [
                "admin",
            ],

        ]
    ];
    protected array $dataCliente = [
        [
            "name" =>  'Introducción',
            "slug" =>  'intro-cliente',
            "icon" => 'ti ti-home-2',
            "roles" => [
                "cliente-admin",
                "cliente-editor",
            ]
        ],
        [
            "name" =>  'Presupuesto(Cliente)',
            "slug" =>  'presupuesto-cliente',
            "role" => 'cliente',
            "icon" => 'ti ti-currency-dollar',
            "roles" => [
                "cliente-admin",
                "cliente-editor",
            ]
        ],
        [
            "name" =>  'Pedidos(Cliente)',
            "slug" =>  'pedidos-cliente',
            "icon" => 'ti ti-file-description',
            "roles" => [
                "cliente-admin",
                "cliente-editor",
            ]
        ],
        [
            "name" =>  'Facturación (Cliente)',
            "slug" =>  'facturacion-cliente',
            "icon" => 'ti ti-file-dollar',
            "roles" => [
                "cliente-admin",
                "cliente-editor",
            ]
        ],
        [
            "name" =>  'Tarifas (Cliente)',
            "slug" =>  'tarifas-cliente',
            "icon" => 'ti ti-receipt',
            "roles" => [
                "cliente-admin",
                "cliente-editor",
            ]
        ],
        [
            "name" =>  'Mensajería (Cliente)',
            "slug" =>  'messages-cliente',
            "icon" => 'ti ti-message',
            "roles" => [
                "cliente-admin",
                "cliente-editor",
            ]
        ]
    ];
    public function run()
    {

        $wikiSectionModel = model(WikiSectionModel::class);
        $wikiSectionRoleModel = model(WikiSectionRoleModel::class);
        $section_order = 0;
        foreach ($this->dataAdmin as $key => $row) {
            $row['order'] = $section_order;
            $wikiSectionId = $wikiSectionModel->insert($row);
            $section_order++;
            foreach ($row['roles'] as $key => $role) {
                $wikiSectionRoleModel->insert(['wiki_section_id' => $wikiSectionId,"role" => $role]);
                
            }
        }
        foreach ($this->dataCliente as $key => $row) {
            $row['order'] = $section_order;
            $wikiSectionId =  $wikiSectionModel->insert($row);
            $section_order++;
            foreach ($row['roles'] as $key => $role) {
                $wikiSectionRoleModel->insert(['wiki_section_id' => $wikiSectionId,"role" => $role]);
            }
        }
    }
}
