<?php

namespace Lc\ShopBundle\Repository;

use App\Entity\DocumentQuotation;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Common\Persistence\ManagerRegistry;
use Lc\ShopBundle\Context\DefaultRepositoryInterface;
use Lc\ShopBundle\Context\DocumentInterface;

/**
 * @method Document|null find($id, $lockMode = null, $lockVersion = null)
 * @method Document|null findOneBy(array $criteria, array $orderBy = null)
 * @method Document[]    findAll()
 * @method Document[]    findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
 */
class DocumentRepository extends BaseRepository implements DefaultRepositoryInterface
{
        public function getInterfaceClass()
        {
                return DocumentInterface::class;
        }

        public function findLastInvoice()
        {
                $query = $this->findByMerchantQuery();
                $query->orderBy('e.createdAt', 'DESC');
                $query->setMaxResults(1);
                return $query->getQuery()->getOneOrNullResult();
        }
}
