Spaces:
No application file
No application file
File size: 1,896 Bytes
d2897cd |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
<?php
namespace Mautic\LeadBundle\Entity;
use Mautic\CoreBundle\Entity\CommonRepository;
/**
* @extends CommonRepository<LeadCategory>
*/
class LeadCategoryRepository extends CommonRepository
{
/**
* @return array<mixed, array<string, mixed>>
*/
public function getLeadCategories(Lead $lead): array
{
$q = $this->_em->getConnection()->createQueryBuilder()
->select('lc.id, lc.category_id, lc.date_added, lc.manually_added, lc.manually_removed, c.alias, c.title')
->from(MAUTIC_TABLE_PREFIX.'lead_categories', 'lc')
->join('lc', MAUTIC_TABLE_PREFIX.'categories', 'c', 'c.id = lc.category_id')
->where('lc.lead_id = :lead')
->andWhere('lc.manually_removed = 0')
->setParameter('lead', $lead->getId());
$results = $q->executeQuery()
->fetchAllAssociative();
$categories = [];
foreach ($results as $category) {
$categories[$category['category_id']] = $category;
}
return $categories;
}
/**
* @return mixed[]
*/
public function getUnsubscribedLeadCategories(Lead $lead): array
{
$q = $this->_em->getConnection()->createQueryBuilder()
->select('lc.id, lc.category_id, lc.date_added, lc.manually_added, lc.manually_removed, c.alias, c.title')
->from(MAUTIC_TABLE_PREFIX.'lead_categories', 'lc')
->join('lc', MAUTIC_TABLE_PREFIX.'categories', 'c', 'c.id = lc.category_id')
->where('lc.lead_id = :lead')
->andWhere('lc.manually_removed = 1')
->setParameter('lead', $lead->getId());
$results = $q->executeQuery()->fetchAllAssociative();
$categories = [];
foreach ($results as $category) {
$categories[$category['category_id']] = $category;
}
return $categories;
}
}
|