<?php

namespace Database\Seeders;

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

class TestCompanySeeder extends Seeder
{
    public function run(): void
    {
        $company = Company::firstOrCreate(
            ['email' => 'testcompany@sarkinmota.local'],
            [
                'name' => 'Test Company Ltd',
                'code' => 'TCL001',
                'industry' => 'Technology',
                'registration_number' => 'RC-123456',
                'tax_id' => 'TAX-789012',
                'email' => 'testcompany@sarkinmota.local',
                'phone' => '+234 800 123 4567',
                'address' => '123 Test Street, Lagos, Nigeria',
                'city' => 'Lagos',
                'country' => 'Nigeria',
                'status' => 'active',
                'employee_count' => 25,
                'annual_revenue' => 50000000,
                'founded_date' => '2020-01-15',
                'website' => 'https://testcompany.local',
                'description' => 'A test company for demonstration purposes',
                'is_holding_company' => false,
            ]
        );

        $user = User::firstOrCreate(
            ['email' => 'company@sarkinmota.local'],
            [
                'name' => 'Company Manager',
                'email' => 'company@sarkinmota.local',
                'password' => Hash::make('password123'),
                'company_id' => $company->id,
                'status' => 'active',
            ]
        );

        if (!$user->hasRole('Company Admin')) {
            $user->assignRole('Company Admin');
        }

        $this->command->info('Test company seeded successfully!');
        $this->command->info('Login: company@sarkinmota.local / password123');
    }
}
