<?php
/**
 * Get FAQ by ID for editing
 * File: admin/faq-get.php
 */

require_once '../app/Core/init.php';
Auth::requireAdmin();

header('Content-Type: application/json');

if (!isset($_GET['id'])) {
    echo json_encode(['success' => false]);
    exit;
}

$faq_model = new Faq();
$faq = $faq_model->find((int)$_GET['id']);

if ($faq) {
    echo json_encode([
        'success' => true,
        'faq' => [
            'id' => $faq['id'],
            'question' => $faq['question'],
            'answer' => $faq['answer'],
            'category' => $faq['category'],
            'display_order' => $faq['display_order'] ?? 0,
            'is_active' => $faq['is_active'],
            'is_featured' => $faq['is_featured']
        ]
    ]);
} else {
    echo json_encode(['success' => false]);
}