Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

NewsRepository.php 1.0KB

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. namespace Lc\ShopBundle\Repository;
  3. use App\Entity\News;
  4. use Lc\ShopBundle\Context\DefaultRepositoryInterface;
  5. use Lc\ShopBundle\Context\NewsInterface;
  6. /**
  7. * @method News|null find($id, $lockMode = null, $lockVersion = null)
  8. * @method News|null findOneBy(array $criteria, array $orderBy = null)
  9. * @method News[] findAll()
  10. * @method News[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
  11. */
  12. class NewsRepository extends BaseRepository implements DefaultRepositoryInterface
  13. {
  14. public function getInterfaceClass()
  15. {
  16. return NewsInterface::class;
  17. }
  18. public function findLatests($maxResults = 0)
  19. {
  20. $result = $this->findByMerchantQuery()
  21. ->orderBy('e.date', 'DESC') ;
  22. $result->andWhere('e.status = 1') ;
  23. if($maxResults) {
  24. $result->setMaxResults($maxResults) ;
  25. }
  26. return $result->getQuery()->getResult() ;
  27. }
  28. }