<?php

namespace Database\Seeders;

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

class TahunAjaranSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        // Calculate current academic year
        $currentYear = date('Y');
        $currentMonth = date('n');
        
        // If we're in July (7) or later, it's the new academic year
        if ($currentMonth >= 7) {
            $tahunAjaran = $currentYear . '/' . ($currentYear + 1);
        } else {
            $tahunAjaran = ($currentYear - 1) . '/' . $currentYear;
        }
        
        Setting::updateOrCreate(
            ['key' => 'tahun_ajaran_aktif'],
            [
                'value' => $tahunAjaran,
                'group' => 'akademik',
                'description' => 'Tahun ajaran yang sedang aktif'
            ]
        );
        
        $this->command->info('Tahun Ajaran Aktif: ' . $tahunAjaran);
    }
}
