<?php
/**
 *
 * @version     1.0.$Revision:$
 * @version     SVN: $Id:$
 * @package     Core\phpAPI
 * @subpackage  Seeders
 * @author      Wassilios Meletiadis <wassilios.meletiadis@bplan-solutions.de>
 * @copyright   Copyright (C) 2025, 2026 Wassilios Meletiadis <https://www.bplan-solutions.de/>
 * /Δ\
 */

namespace BplanBase\Globals\Database\Seeders\Dev;


use BplanBase\Globals\Models\Tenant;
use Carbon\Carbon;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;


/**
 *
 * @author      Wassilios Meletiadis <wassilios.meletiadis@bplan-solutions.de>
 */
class CombinedTenantSeeder 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');

		$SystemTenant = Tenant::where('identifier', 'System')->first();

		/*
		**	Second Level Tenants */
		Tenant::insert([
			[
				'uuid' => '00010000-0000-0000-0000-000000000000',
				'active' => 1,
				'created_at' => $date,
				'updated_at' => $date,
				'identifier' => 'Sportbund',
				'master_id' => $SystemTenant->id,
                'path' => Tenant::nextPath($SystemTenant->path),
			],

		]);
		/*
		**	Third Level Tenants */
		$Tenant = Tenant::where('identifier', 'Sportbund')->first();

        $offset = 0;

		Tenant::insert([
			[
				'uuid' => '00010100-0000-0000-0000-000000000000',
				'active' => 1,
				'created_at' => $date,
				'updated_at' => $date,
				'identifier' => 'Landessportbund NRW',
				'master_id' => $Tenant->id,
                'path' => Tenant::nextPath($Tenant->path, $offset++),
			],
			[
				'uuid' => '00010200-0000-0000-0000-000000000000',
				'active' => 1,
				'created_at' => $date,
				'updated_at' => $date,
				'identifier' => 'Landessportbund RP',
				'master_id' => $Tenant->id,
                'path' => Tenant::nextPath($Tenant->path, $offset++),
			],
		]);

		/*
		**	Fourth Level Tenants */
		$Tenant = Tenant::where('identifier', 'Landessportbund NRW')->first();

		Tenant::insert([
			[
				'uuid' => '00010101-0000-0000-0000-000000000000',
				'active' => 1,
				'created_at' => $date,
				'updated_at' => $date,
				'identifier' => 'Kreissportbund Porz',
				'master_id' => $Tenant->id,
                'path' => Tenant::nextPath($Tenant->path),
			],
		]);

		$Tenant = Tenant::where('identifier', 'Landessportbund RP')->first();

		Tenant::insert([
			[
				'uuid' => '00010201-0000-0000-0000-000000000000',
				'active' => 1,
				'created_at' => $date,
				'updated_at' => $date,
				'identifier' => 'Kreissportbund Neuwied',
				'master_id' => $Tenant->id,
                'path' => Tenant::nextPath($Tenant->path),
			],

		]);

    } // run()

} // class CombinedTenantSeeder extends Seeder {}
