Deploy: 2026-05-21 15:33:14
This commit is contained in:
27
backend/app/Models/Campaign.php
Normal file
27
backend/app/Models/Campaign.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user