create($data); } /** * Retrieve and decrypt templates */ public function findAllByCompany(int $companyId) { $templates = $this->db->query( "SELECT * FROM {$this->table} WHERE company_id = ? ORDER BY id DESC", [$companyId] )->fetchAll(); foreach ($templates as &$template) { if (!empty($template['media_url'])) { $template['media_url'] = Security::decrypt($template['media_url']); } } return $templates; } /** * Get single template and decrypt */ public function findByIdAndCompany(int $id, int $companyId) { $template = $this->db->query( "SELECT * FROM {$this->table} WHERE id = ? AND company_id = ? LIMIT 1", [$id, $companyId] )->fetch(); if ($template && !empty($template['media_url'])) { $template['media_url'] = Security::decrypt($template['media_url']); } return $template; } }