prepareQueryFindRegistrationsForCustomer()->all(); } public function findCustomerRegistrations() { $interval = EventInterval::createInterval(); return EventRegistration::find() ->innerJoinWith('event') ->andWhere(['and', ['>=', 'event.start', $interval->firstActiveDate->getTimestamp()], ['id_customer' => \Yii::$app->user->getId()] ])->all(); } public function findRegistration($id_registration) { return $this->prepareQueryFindRegistrationsForCustomer() ->andWhere(['event_registration.id' => $id_registration]) ->one(); } /** * Prepare a query to get registrations for customer * @return ActiveQuery query * @throws \Exception */ private function prepareQueryFindRegistrationsForCustomer(){ $interval = EventInterval::createInterval(); return EventRegistrationAvailable::find() ->innerJoinWith('event') ->andWhere(['and', ['>=', 'event.start', $interval->firstActiveDate->getTimestamp()], ['id_customer' => \Yii::$app->user->getId()] ]); } }