<?php

namespace App\Models;

use App\Core\Model;

class ForumCategory extends Model
{
    protected $table = 'forum_categories';
    protected $primaryKey = 'id';

    public function getActive()
    {
        $stmt = $this->db->query("SELECT c.*, (SELECT COUNT(*) FROM forum_topics WHERE category_id = c.id AND status = 'active') as topic_count FROM {$this->table} c WHERE c.is_active = 1 ORDER BY c.sort_order ASC");
        return $stmt->fetchAll(\PDO::FETCH_OBJ);
    }
}
