<?php

namespace App\Models;

/**
 * Campaign Model
 * Manages broadcast campaigns linking templates to contact groups.
 */
class Campaign extends BaseModel
{
    protected static string $table = 'campaigns';

    /**
     * Get all campaigns for a company
     */
    public static function findAllByCompany(int $companyId)
    {
        return \App\Core\Database::select(
            "SELECT c.*, g.name as group_name, t.name as template_name 
             FROM " . static::$table . " c
             LEFT JOIN contact_groups g ON c.group_id = g.id
             LEFT JOIN templates t ON c.template_id = t.id
             WHERE c.company_id = ? ORDER BY c.id DESC",
            [$companyId]
        );
    }
}
