<?php
namespace App\Repository;
use App\Entity\Conversation;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @extends ServiceEntityRepository<Conversation>
*
* @method Conversation|null find($id, $lockMode = null, $lockVersion = null)
* @method Conversation|null findOneBy(array $criteria, array $orderBy = null)
* @method Conversation[] findAll()
* @method Conversation[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class ConversationRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Conversation::class);
}
public function findById($id): ?Conversation
{
return $this->createQueryBuilder('c')
->andWhere('c.id = :val')
->setParameter('val', $id)
->getQuery()
->getOneOrNullResult();
}
public function findAllByStatus($status): ?array
{
return $this->createQueryBuilder('c')
->leftJoin('c.fk_image', 'i')
->leftJoin('i.fk_user', 'u')
->andWhere('c.type = :val')
->setParameter('val', $status)
->orderBy('c.id', 'ASC')
->getQuery()
->getResult();
}
// /**
// * @return Conversation[] Returns an array of Conversation objects
// */
// public function findByExampleField($value): array
// {
// return $this->createQueryBuilder('c')
// ->andWhere('c.exampleField = :val')
// ->setParameter('val', $value)
// ->orderBy('c.id', 'ASC')
// ->setMaxResults(10)
// ->getQuery()
// ->getResult()
// ;
// }
// public function findOneBySomeField($value): ?Conversation
// {
// return $this->createQueryBuilder('c')
// ->andWhere('c.exampleField = :val')
// ->setParameter('val', $value)
// ->getQuery()
// ->getOneOrNullResult()
// ;
// }
}