您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

VisitorRepositoryQuery.php 1.1KB

3 年前
3 年前
3 年前
3 年前
12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace Lc\CaracoleBundle\Repository\User;
  3. use Knp\Component\Pager\PaginatorInterface;
  4. use Lc\SovBundle\Repository\AbstractRepositoryQuery;
  5. class VisitorRepositoryQuery extends AbstractRepositoryQuery
  6. {
  7. public function __construct(VisitorRepository $repository, PaginatorInterface $paginator)
  8. {
  9. parent::__construct($repository, 'visitor', $paginator);
  10. }
  11. public function filterByCookie(string $cookie = null)
  12. {
  13. if(is_null($cookie)) {
  14. return $this->andWhere('.cookie IS NULL');
  15. }
  16. else {
  17. return $this
  18. ->andWhere('.cookie LIKE :cookie')
  19. ->setParameter('cookie', $cookie);
  20. }
  21. }
  22. public function filterByLastAccess(\DateTime $lastAccess)
  23. {
  24. return $this
  25. ->andWhere('.lastAccess < :lastAccess')
  26. ->setParameter('lastAccess', $lastAccess);
  27. }
  28. public function filterByTotalVisit(int $totalVisit)
  29. {
  30. return $this
  31. ->andWhere('.totalVisit = :totalVisit')
  32. ->setParameter('totalVisit', $totalVisit);
  33. }
  34. }