<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use App\Models\PerizinanStatus;

class CheckPerizinanData extends Command
{
    protected $signature = 'perizinan:check';
    protected $description = 'Check synced perizinan data';

    public function handle()
    {
        $this->info('📊 Checking synced perizinan data...');

        $data = PerizinanStatus::orderBy('Kategori_ID')->orderBy('StatusID')->get();

        if ($data->isEmpty()) {
            $this->warn('No data found in database');
            return;
        }

        $groupedData = $data->groupBy('Kategori_ID');

        foreach ($groupedData as $kategori => $items) {
            $this->newLine();
            $this->info("=== {$kategori} ===");

            foreach ($items as $item) {
                $this->line("  {$item->StatusID}: {$item->Label} = {$item->Value}");
            }
        }

        $this->newLine();
        $this->info("Total records: " . $data->count());
    }
}
