<?php

namespace Database\Seeders;

use App\Models\ContractType;
use App\Models\Person\AddressType;
use App\Models\Person\Person;
use App\Models\Person\PersonGroup;
use App\Models\Person\PersonType;
use App\Models\Person\PhoneType;
use Illuminate\Database\Seeder;

class PersonSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        //
        $personTypes = [
            ['name' => 'legal', 'description' => ''],
            ['name' => 'natural', 'description' => ''],
        ];

        $personGroups = [
            ['name' => 'naročnik', 'description' => '', 'color_tag' => 'blue-500'],
            ['name' => 'primer naročnika', 'description' => '', 'color_tag' => 'red-400'],
        ];

        $phoneTypes = [
            ['name' => 'mobile', 'description' => ''],
            ['name' => 'telephone', 'description' => ''],
        ];

        $addressTypes = [
            ['name' => 'permanent', 'description' => ''],
            ['name' => 'temporary', 'description' => ''],
        ];

        $contractTypes = [
            ['name' => 'early', 'description' => ''],
            ['name' => 'hard', 'description' => ''],
        ];

        foreach ($personTypes as $pt) {
            PersonType::create($pt);
        }

        foreach ($personGroups as $pg) {
            PersonGroup::create($pg);
        }

        foreach ($phoneTypes as $pt) {
            PhoneType::create($pt);
        }

        foreach ($addressTypes as $at) {
            AddressType::create($at);
        }

        foreach ($contractTypes as $ct) {
            ContractType::create($ct);
        }

        // client
        Person::create([
            'nu' => rand(100000, 200000),
            'first_name' => '',
            'last_name' => '',
            'full_name' => 'Naročnik d.o.o.',
            'gender' => 'm',
            'birthday' => '2000-01-01',
            'tax_number' => '22424345',
            'social_security_number' => '22525252233656',
            'description' => 'sdwwf',
            'group_id' => 1,
            'type_id' => 1,
            'user_id' => 1,
        ])->client()->create();

        // debtors
        Person::create([
            'nu' => rand(100000, 200000),
            'first_name' => 'test',
            'last_name' => 'test',
            'full_name' => 'test test',
            'gender' => 'm',
            'birthday' => '2000-01-01',
            'tax_number' => '22424345',
            'social_security_number' => '22525252233656',
            'description' => 'sdwwf',
            'group_id' => 2,
            'type_id' => 2,
            'user_id' => 1,
        ])->clientCase()->create([
            'client_id' => 1,
        ]);

        Person::create([
            'nu' => rand(100000, 200000),
            'first_name' => 'test2',
            'last_name' => 'test2',
            'full_name' => 'test2 test2',
            'gender' => 'm',
            'birthday' => '1992-01-01',
            'tax_number' => '2425233',
            'social_security_number' => '22522312314',
            'description' => 'dw323',
            'group_id' => 2,
            'type_id' => 2,
            'user_id' => 1,
        ])->clientCase()->create([
            'client_id' => 1,
        ]);

        // client
        Person::create([
            'nu' => rand(100000, 200000),
            'first_name' => '',
            'last_name' => '',
            'full_name' => 'test d.o.o.',
            'gender' => 'm',
            'birthday' => '2000-01-01',
            'tax_number' => '22424345',
            'social_security_number' => '22525252233656',
            'description' => 'sdwwf',
            'group_id' => 1,
            'type_id' => 1,
            'user_id' => 1,
        ])->client()->create();

        // debtors
        Person::create([
            'nu' => rand(100000, 200000),
            'first_name' => 'test3',
            'last_name' => 'test3',
            'full_name' => 'test3 test3',
            'gender' => 'm',
            'birthday' => '2000-01-01',
            'tax_number' => '22424345',
            'social_security_number' => '22525252233656',
            'description' => 'sdwwf',
            'group_id' => 2,
            'type_id' => 2,
            'user_id' => 1,
        ])->clientCase()->create(
            [
                'client_id' => 2,
            ]
        );

        Person::create([
            'nu' => rand(100000, 200000),
            'first_name' => '',
            'last_name' => '',
            'full_name' => 'test4 d.o.o.',
            'gender' => 'm',
            'birthday' => '1992-01-01',
            'tax_number' => '2425233',
            'social_security_number' => '22522312314',
            'description' => 'dw323',
            'group_id' => 2,
            'type_id' => 1,
            'user_id' => 1,
        ])->clientCase()->create(
            [
                'client_id' => 2,
            ]
        );

    }
}
