<?php

declare(strict_types=1);

use Hyperf\Database\Seeders\Seeder;
use App\Models\User;

use Hypervel\Support\Facades\Hash;
use Hypervel\Support\Str;

class UserSeeder extends Seeder
{
    protected $users = [
        [
            'name' => 'System Administrator',
            'mobile_number' => '777',
            'nickname' => 'admin',
            'username' => 'admin',
            'email' => 'admin@example.com',
            'password' => 'OmegaPsilon32!',
            'acct_type' => 'super_admin',
        ],
        [
            'name' => 'Punong Barangay',
            'mobile_number' => '09111111111',
            'nickname' => 'captain',
            'username' => 'test_captain',
            'password' => 'TetraOmega21!',
            'acct_type' => 'punong_barangay',
        ],
        [
            'name' => 'Barangay Secretary',
            'mobile_number' => '09222222222',
            'nickname' => 'secretary',
            'username' => 'test_secretary',
            'password' => 'HeliosAlpha21!',
            'acct_type' => 'secretary',
        ],
        [
            'name' => 'Barangay Treasurer',
            'mobile_number' => '09333333333',
            'nickname' => 'treasurer',
            'username' => 'test_treasurer',
            'password' => 'ParagonSigma51!',
            'acct_type' => 'treasurer',
        ],
        [
            'name' => 'Sample Kagawad',
            'mobile_number' => '09444444444',
            'nickname' => 'kagawad',
            'username' => 'test_kagawad',
            'password' => 'MilipedeAstra21!',
            'acct_type' => 'kagawad',
        ],
        [
            'name' => 'Sample Resident',
            'mobile_number' => '09555555555',
            'nickname' => 'resident',
            'username' => 'test_resident',
            'password' => 'OrionDraconis21!',
            'acct_type' => 'resident',
        ],
    ];

    public function run()
    {
        foreach ($this->users as $data) {
            User::firstOrCreate(['mobile_number' => $data['mobile_number']], [
                'name' => $data['name'],
                'nickname' => $data['nickname'] ?? null,
                'username' => $data['username'] ?? null,
                'email' => $data['email'] ?? null,
                'email_verified_at' => now(),
                'mobile_verified_at' => now(),
                'password' => Hash::make($data['password']),
                'acct_type' => $data['acct_type'],
                'total_balance' => 0,
                'total_credit' => 0,
                'created_by' => null,
                'updated_by' => null,
                'active' => true,
                'parentuid' => null,
                'targetuids' => null,
                'notes' => null,
                'exec_command' => null,
                'settings' => null,
                'multiple_logins' => false,
                'referralcode' => null,
                'photourl' => null,
                'logs' => null,
                'cart' => null,
            ]);
        }
    }
}
