28 lines
690 B
PHP
28 lines
690 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
/**
|
|
* Campaign Model
|
|
* Manages broadcast campaigns linking templates to contact groups.
|
|
*/
|
|
class Campaign extends BaseModel
|
|
{
|
|
protected string $table = 'campaigns';
|
|
|
|
/**
|
|
* Get all campaigns for a company
|
|
*/
|
|
public function findAllByCompany(int $companyId)
|
|
{
|
|
return $this->db->query(
|
|
"SELECT c.*, g.name as group_name, t.name as template_name
|
|
FROM {$this->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]
|
|
)->fetchAll();
|
|
}
|
|
}
|