- <?php
-
- namespace domain\User\User;
-
- use domain\Producer\Producer\Producer;
- use domain\_\AbstractRepositoryQuery;
-
- class UserRepositoryQuery extends AbstractRepositoryQuery
- {
- protected UserDefinition $definition;
-
- public function loadDependencies(): void
- {
- $this->loadDefinition(UserDefinition::class);
- }
-
- public function filterByPasswordResetToken(string $token): self
- {
- $this->andWhere(['password_reset_token' => $token]);
- return $this;
- }
-
- public function filterByEmail(string $email): self
- {
- $this->andWhere(['email' => $email]);
- return $this;
- }
-
- public function filterByUsername(string $username): self
- {
- $this->andWhere(['username' => $username]);
- return $this;
- }
-
- public function filterByProducer(Producer $producer): self
- {
- $this->andWhere(['user.id_producer' => $producer->id]);
- return $this;
- }
-
- public function filterByStatus(string $status): self
- {
- $this->andWhere(['user.status' => $status]);
- return $this;
- }
-
- public function isStatusProducer(): self
- {
- return $this->filterByStatus(User::STATUS_PRODUCER);
- }
-
- public function isStatusUser(): self
- {
- return $this->filterByStatus(User::STATUS_ACTIVE);
- }
-
- public function filterByDateLastConnectionLessThanFewMinutes(): self
- {
- $date = new \DateTime('-5 minutes');
- $this->andWhere('user.date_last_connection >= :date')
- ->addParams(['date' => $date->format('Y-m-d H:i:s')]);
- return $this;
- }
- }
|