Feat: Add contacts

This commit is contained in:
Björn Fromme committed 2023-10-16 12:05:18 +02:00
1 parent f5fee787a0
commit 3fd4c6ca54
19 files changed
+658 -2

No files matched your search

+50
View File
@@ -0,0 +1,50 @@
<?php
namespace App\Repository;
use App\Entity\Contact;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @extends ServiceEntityRepository<Contact>
*
* @method Contact|null find($id, $lockMode = null, $lockVersion = null)
* @method Contact|null findOneBy(array $criteria, array $orderBy = null)
* @method Contact[] findAll()
* @method Contact[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class ContactRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Contact::class);
}
public function getGeneralContacts(): array
{
$qb = $this->createQueryBuilder('contact');
return $qb
->leftJoin('contact.photo', 'photo')
->where($qb->expr()->isNull('contact.destination'))
->orderBy('contact.name', 'ASC')
->getQuery()
->getResult()
;
}
public function getDestinationContacts(): array
{
$qb = $this->createQueryBuilder('contact');
return $qb
->leftJoin('contact.photo', 'photo')
->where($qb->expr()->isNotNull('contact.destination'))
->orderBy('contact.name', 'ASC')
->addOrderBy('contact.destination', 'ASC')
->getQuery()
->getResult()
;
}
}