<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use App\Models\Setting;

class SettingsSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $settings = [
            // Application Settings
            'app.name' => 'Seraph3',
            'app.version' => '3.0.0',
            'app.timezone' => 'Europe/London',
            'app.locale' => 'en',
            
            // Company Information
            'company.name' => 'IT Support Services Ltd',
            'company.address' => '123 Technology Street',
            'company.city' => 'Manchester',
            'company.postcode' => 'M1 1AA',
            'company.phone' => '0161 123 4567',
            'company.email' => 'info@seraph.local',
            'company.website' => 'https://seraph.local',
            'company.vat_number' => 'GB123456789',
            'company.registration_number' => '12345678',
            
            // Business Settings
            'business.default_vat_rate' => 20,
            'business.currency' => 'GBP',
            'business.currency_symbol' => '£',
            'business.working_hours_start' => '09:00',
            'business.working_hours_end' => '17:00',
        ];

        foreach ($settings as $key => $value) {
            // Use Laravel5 style - check if exists, then update or create
            $setting = Setting::find($key);
            if ($setting) {
                $setting->value = is_string($value) ? $value : json_encode($value);
                $setting->save();
            } else {
                $setting = new Setting();
                $setting->key = $key;
                $setting->value = is_string($value) ? $value : json_encode($value);
                $setting->save();
            }
        }

        $this->command->info('Created ' . count($settings) . ' system settings');
    }
} 