customer available events improvements
This commit is contained in:
@@ -9,15 +9,11 @@
|
||||
namespace customerapi\controllers;
|
||||
|
||||
|
||||
use common\manager\EventRegistrationManager;
|
||||
use customerapi\manager\EventRegistrationManager;
|
||||
use common\models\CardEventRegistrationForm;
|
||||
use common\models\Customer;
|
||||
use customerapi\models\available\EventInterval;
|
||||
use customerapi\models\registrations\EventRegistrationAvailable;
|
||||
use Exception;
|
||||
use Throwable;
|
||||
use Yii;
|
||||
use yii\db\ActiveQuery;
|
||||
use yii\web\Response;
|
||||
|
||||
/** @noinspection PhpUnused */
|
||||
@@ -32,8 +28,8 @@ class EventRegistrationController extends CustomerApiController
|
||||
*/
|
||||
public function actionIndex()
|
||||
{
|
||||
$registrations =$this->prepareQueryFindRegistrationsForCustomer()->all();
|
||||
return $this->asJson( $registrations );
|
||||
$registrationManager = new EventRegistrationManager();
|
||||
return $this->asJson( $registrationManager->findCustomerRegistrationsWithEvent() );
|
||||
}
|
||||
|
||||
/** @noinspection PhpUnused */
|
||||
@@ -44,35 +40,15 @@ class EventRegistrationController extends CustomerApiController
|
||||
*/
|
||||
public function actionRegistration($id_registration)
|
||||
{
|
||||
$registrations = $this->prepareQueryFindRegistrationsForCustomer()
|
||||
->andWhere(['event_registration.id' => $id_registration])
|
||||
->one();
|
||||
$registrationManager = new EventRegistrationManager();
|
||||
return $this->asJson(
|
||||
$registrations
|
||||
);
|
||||
$registrationManager->findRegistration($id_registration)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 */
|
||||
|
||||
Reference in New Issue
Block a user