<?php

declare(strict_types=1);

namespace Database\Seeders;

use App\Models\User;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Hash;

class AdminUserSeeder extends Seeder
{
    public function run(): void
    {
        $admin = User::firstOrCreate(
            ['email' => 'admin@ezscale.cloud'],
            [
                'name' => 'Admin User',
                'password' => Hash::make('admin123!'),
                'status' => 'active',
                'email_verified_at' => now(),
            ]
        );

        if (! $admin->hasRole('admin')) {
            $admin->assignRole('admin');
        }

        if (! $admin->profile) {
            $admin->profile()->create([]);
        }

        $customer = User::firstOrCreate(
            ['email' => 'user@ezscale.dev'],
            [
                'name' => 'Test Customer',
                'password' => Hash::make('user123!'),
                'status' => 'active',
                'email_verified_at' => now(),
            ]
        );

        if (! $customer->hasRole('customer')) {
            $customer->assignRole('customer');
        }

        if (! $customer->profile) {
            $customer->profile()->create([]);
        }
    }
}
