feat: Add tagging system for SMS logs and templates
- Introduced a `tag` field in the `SmsLog` entity to categorize SMS messages. - Updated the `SmsService` to handle the new `tag` parameter during SMS dispatch. - Implemented a `SmsTextResolver` service to resolve SMS message templates based on tags. - Created a new `SmsMessageTemplate` entity for editable SMS templates with placeholders. - Added endpoints for managing SMS message templates in the admin panel. - Enhanced existing SMS dispatching methods across various controllers to utilize the tagging system. - Migrated the database to include the new `tag` field and created a seeding command for default SMS templates. - Updated admin API to filter SMS logs by tag and include tag information in responses.
This commit is contained in:
@@ -1264,12 +1264,17 @@ class AdminApiController extends BaseController
|
||||
{
|
||||
$page = max(1, (int) $request->query->get('page', 1));
|
||||
$limit = min(100, max(1, (int) $request->query->get('limit', 15)));
|
||||
$tag = trim((string) $request->query->get('tag', ''));
|
||||
|
||||
$qb = $this->em->createQueryBuilder()
|
||||
->select('s.uuid, s.mobile, s.message, s.provider, s.success, s.createdAt')
|
||||
->select('s.uuid, s.mobile, s.message, s.provider, s.success, s.tag, s.createdAt')
|
||||
->from(SmsLog::class, 's')
|
||||
->orderBy('s.createdAt', 'DESC');
|
||||
|
||||
if ($tag !== '') {
|
||||
$qb->andWhere('s.tag = :tag')->setParameter('tag', $tag);
|
||||
}
|
||||
|
||||
$total = (clone $qb)->select('COUNT(s.id)')->getQuery()->getSingleScalarResult();
|
||||
|
||||
$rows = $qb->setFirstResult(($page - 1) * $limit)->setMaxResults($limit)
|
||||
@@ -1281,6 +1286,7 @@ class AdminApiController extends BaseController
|
||||
'message' => $l['message'],
|
||||
'status' => $l['success'] ? 'sent' : 'failed',
|
||||
'provider' => $l['provider'],
|
||||
'tag' => $l['tag'],
|
||||
'sent_at' => date('c', (int) $l['createdAt']),
|
||||
'created_at' => date('c', (int) $l['createdAt']),
|
||||
], $rows);
|
||||
|
||||
Reference in New Issue
Block a user