zend-blog-3-backend

Форк
0
/
ViewCommentRepository.php 
40 строк · 963.0 Байт
1
<?php
2

3
namespace App\Repository;
4

5
use App\Entity\Post;
6
use App\Entity\ViewComment;
7
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
8
use Doctrine\Persistence\ManagerRegistry;
9

10
class ViewCommentRepository extends ServiceEntityRepository
11
{
12
    use ListQueryTrait;
13

14
    /**
15
     * @param ManagerRegistry $registry
16
     */
17
    public function __construct(ManagerRegistry $registry)
18
    {
19
        parent::__construct($registry, ViewComment::class);
20
    }
21

22
    /**
23
     * @param Post $post
24
     *
25
     * @return ViewComment[]
26
     */
27
    public function getCommentsByPost(Post $post): array
28
    {
29
        $qb = $this->createQueryBuilder('c');
30

31
        $qb
32
            ->where($qb->expr()->eq('c.post', ':post'))
33
            ->andWhere($qb->expr()->eq('c.deleted', $qb->expr()->literal(false)))
34
            ->setParameter('post', $post->getId())
35
            ->orderBy('c.timeCreated')
36
        ;
37

38
        return $qb->getQuery()->getResult();
39
    }
40
}
41

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.