<?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')->orderBy('status_id')->get();

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

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

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

            foreach ($items as $item) {
                $this->line("  {$item->status_id}: {$item->label} = {$item->value}");
            }
        }

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