<?php
namespace App\Models;

use App\Core\Model;

class Tag extends Model {
    protected static string $table = 'tags';

    public static function getAllWithCount(): array {
        $stmt = self::db()->query("
            SELECT t.*, COUNT(ct.contact_id) as contact_count 
            FROM tags t
            LEFT JOIN contact_tags ct ON t.id = ct.tag_id
            GROUP BY t.id
            ORDER BY t.name ASC
        ");
        return $stmt->fetchAll();
    }
}
