<?php

namespace Database\Seeders;

use App\Models\User;
use App\Models\Contractor;
use Illuminate\Database\Seeder;

class ContractorSeeder extends Seeder
{
    public function run(): void
    {
        // Cari user contractor
        $user = User::where('email', 'kontraktor@tunjuk-i.id')->first();

        if ($user) {
            Contractor::updateOrCreate(
                ['user_id' => $user->id],
                [
                    'business_name' => 'PT. Papua Mandiri',
                    'short_name' => 'PT. PM',
                    'business_type' => 'pt',
                    'oap_status' => 'verified',
                    'oap_verified_at' => now(),
                    'address' => 'Jl. Raya Sentani No. 45, Doyo Baru',
                    'province' => 'Papua',
                    'regency' => 'Jayapura',
                    'district' => 'Sentani',
                    'village' => 'Doyo Baru',
                    'postal_code' => '99352',
                    'phone' => '081234567890',
                    'email' => 'info@papua-mandiri.id',
                    'skp_remaining' => 5,
                    'rating_avg' => 4.8,
                    'is_active' => true,
                ]
            );

            $this->command->info('✅ Contractor created/updated successfully!');
        } else {
            $this->command->warn('⚠️ User contractor not found!');
        }
    }
}