<?php

declare(strict_types=1);

namespace App\Models;

use CodeIgniter\Model;

/**
 * 사용자 의견(피드백) 모델.
 */
class FeedbackModel extends Model
{
    use \App\Models\Traits\Auditable;

    protected $table         = 'feedback';
    protected $primaryKey    = 'fb_idx';
    protected $returnType    = 'object';
    protected $useTimestamps = true;
    protected $createdField  = 'fb_regdate';
    protected $updatedField  = 'fb_updated';
    protected $dateFormat    = 'datetime';

    protected $allowedFields = [
        'fb_lg_idx', 'fb_mb_idx', 'fb_mb_name', 'fb_mb_level',
        'fb_content', 'fb_page_url', 'fb_page_title', 'fb_screenshot',
        'fb_user_agent', 'fb_status', 'fb_admin_memo',
    ];

    /** 허용 상태 값 */
    public const STATUSES = ['new', 'in_progress', 'answered', 'done', 'hold'];

    public static function statusLabel(string $s): string
    {
        return [
            'new'         => '접수',
            'in_progress' => '처리중',
            'answered'    => '답변 완료',
            'done'        => '완료',
            'hold'        => '보류',
        ][$s] ?? $s;
    }
}
