Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

30 lines
978B

  1. <?php
  2. namespace domain\Subscription\Subscription;
  3. use domain\User\User\User;
  4. use domain\_\AbstractRepositoryQuery;
  5. class SubscriptionRepositoryQuery extends AbstractRepositoryQuery
  6. {
  7. protected SubscriptionDefinition $definition;
  8. public function loadDependencies(): void
  9. {
  10. $this->loadDefinition(SubscriptionDefinition::class);
  11. }
  12. public function filterByUser(User $user): self
  13. {
  14. $this->andWhere(['subscription.id_user' => $user->id]);
  15. return $this;
  16. }
  17. public function filterByCreatedOrUpdatedByUserDuringPastWeek(): self
  18. {
  19. $datePastWeek = new \DateTime('-7 days');
  20. $this->andWhere('(subscription.id_user = subscription.id_created_by AND subscription.created_at >= :date_past_week) OR (subscription.id_user = subscription.id_updated_by AND subscription.updated_at >= :date_past_week)')
  21. ->addParams(['date_past_week' => $datePastWeek->format('Y-m-d H:i:s')]);
  22. return $this;
  23. }
  24. }