prepareQueryFindRegistrationsForCustomer()->all(); return $this->asJson( $registrations ); } /** @noinspection PhpUnused */ /*** * @param $id_registration * @return Response * @throws Exception */ public function actionRegistration($id_registration) { $registrations = $this->prepareQueryFindRegistrationsForCustomer() ->andWhere(['id_event_registration' => $id_registration]) ->one(); return $this->asJson( $registrations ); } /** * Prepare a query to get registrations for customer * * @return ActiveQuery * @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()] ]); } /** * @noinspection PhpUnused * @param $id_event * @throws Throwable */ public function actionRegister($id_event) { /** @var Customer $customer */ $customer = Yii::$app->user->getIdentity(); $card =$customer->card; $form = new CardEventRegistrationForm(); $form->event_id = $id_event; $form->card_number = $card->number; $manager = new EventRegistrationManager(); $manager->registerCard($form); return $form->registration; } }