<?php
/**
 * Setup Seeder
 *
 * Multi-Tenant-Seeder, der über die Setup-Konfiguration in "etc/setup/globals.php" (im Projekt) gesteuert wird.
 *
 * @version     1.0.$Revision:$
 * @version     SVN: $Id:$
 * @package     bplan-modules/visitor-management
 * @subpackage  Seeders
 * @author      Wassilios Meletiadis <wassilios.meletiadis@bplan-solutions.de>
 * @copyright   Copyright (C) 2025, 2026 bplan-solutions GmbH & Co. KG <https://www.bplan-solutions.de/>
 * /Δ\
 */

namespace BplanBase\Globals\Database\Seeders\Project;


use BplanBase\Globals\Models\Tenant;
use BplanBase\Globals\Models\Role;
use Illuminate\Database\Seeder;
use Illuminate\Support\Str;


/**
 *
 * @author      Wassilios Meletiadis <wassilios.meletiadis@bplan-solutions.de>
 */
class RoleSeeder extends Seeder
{

    /**
     * Run the database seeds.
     *
     * @return void
     *
     * @author      Wassilios Meletiadis <wassilios.meletiadis@bplan-solutions.de>
     */
    public function run()
    {
        $date = date('Y-m-d H:i:s');

        $globalsSetup = \BplanBase\Globals\Database\Seeders\DatabaseSeeder::loadConfig();

        foreach ($globalsSetup as $tenant => $globalsConfig) {
            $ProjectTenant = Tenant::where('identifier', $tenant)->first();

            Role::insert([
                // [
                //     'uuid'       => Str::uuid(),
                //     'active'     => 1,
                //     'created_at' => $date,
                //     'updated_at' => $date,
                //     'identifier' => 'SuperUser',
                //     'internal'   => 1,
                //     'labels'     => '{"de": "SuperUser", "en": "SuperUser", "it": "SuperUser"}',
                //     'tenant_id'  => $ProjectTenant->id,
                // ],
                [
                    'uuid'       => Str::uuid(),
                    'active'     => 1,
                    'created_at' => $date,
                    'updated_at' => $date,
                    'identifier' => 'Admin',
                    'internal'   => 0,
                    'labels'     => '{"de": "Administrator", "en": "Administrator", "it": "Amministratore"}',
                    'tenant_id'  => $ProjectTenant->id,
                ],
            ]);

        }
    } // run()

} // class RoleSeeder extends Seeder {}
