<?php

namespace Database\Seeders;

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

class TradePeriodSeeder extends Seeder
{
    public function run(): void
    {
        $universal = [
            ['duration_seconds' => 60, 'profit_percent' => 10, 'min_amount' => 300],
            ['duration_seconds' => 120, 'profit_percent' => 15, 'min_amount' => 5000],
            ['duration_seconds' => 180, 'profit_percent' => 20, 'min_amount' => 20000],
            ['duration_seconds' => 240, 'profit_percent' => 27, 'min_amount' => 40000],
            ['duration_seconds' => 360, 'profit_percent' => 30, 'min_amount' => 100000],
        ];

        foreach ($universal as $period) {
            TradePeriod::updateOrCreate(
                [
                    'duration_seconds' => $period['duration_seconds'],
                    'market_type' => null,
                ],
                $period + ['is_active' => true, 'market_type' => null]
            );
        }

        $metal = [
            ['duration_seconds' => 60, 'profit_percent' => 10, 'min_amount' => 100],
            ['duration_seconds' => 120, 'profit_percent' => 15, 'min_amount' => 500],
            ['duration_seconds' => 180, 'profit_percent' => 20, 'min_amount' => 2000],
            ['duration_seconds' => 240, 'profit_percent' => 27, 'min_amount' => 10000],
            ['duration_seconds' => 360, 'profit_percent' => 30, 'min_amount' => 50000],
        ];

        foreach ($metal as $period) {
            TradePeriod::updateOrCreate(
                [
                    'duration_seconds' => $period['duration_seconds'],
                    'market_type' => 'metal',
                ],
                $period + ['is_active' => true, 'market_type' => 'metal']
            );
        }
    }
}
