<?php

declare(strict_types=1);

namespace MauticPlugin\DealFlowBundle\Entity;

use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;

/** @extends ServiceEntityRepository<DealAttachment> */
class DealAttachmentRepository extends ServiceEntityRepository
{
    public function __construct(ManagerRegistry $registry)
    {
        parent::__construct($registry, DealAttachment::class);
    }

    /**
     * @return list<DealAttachment>
     */
    public function findByDeal(Deal $deal): array
    {
        return $this->findBy(['deal' => $deal], ['createdAt' => 'DESC']);
    }
}
