add customer api
This commit is contained in:
58
customerapi/models/available/EventAvailable.php
Normal file
58
customerapi/models/available/EventAvailable.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace customerapi\models\available;
|
||||
|
||||
|
||||
use common\models\Event;
|
||||
use common\models\EventType;
|
||||
|
||||
class EventAvailable extends Event
|
||||
{
|
||||
|
||||
public $reservationCount;
|
||||
|
||||
protected function getTrainerClass()
|
||||
{
|
||||
// override trainer class to have more control
|
||||
// about json fields
|
||||
return TrainerAvailable::class;
|
||||
}
|
||||
|
||||
protected function getEventTypeClass()
|
||||
{
|
||||
return EventTypeAvailable::class;
|
||||
}
|
||||
|
||||
protected function getRoomClass()
|
||||
{
|
||||
return RoomAvailable::class;
|
||||
}
|
||||
|
||||
|
||||
function fields()
|
||||
{
|
||||
|
||||
$fields = [
|
||||
"id" => "id",
|
||||
"start" => "start",
|
||||
"end" => "end",
|
||||
"seat_count" => "seat_count",
|
||||
"active" => "active",
|
||||
// "reservationCount" => "reservationCount"
|
||||
];
|
||||
$fields['trainer'] = 'trainer';
|
||||
$fields['eventType'] = 'eventType';
|
||||
$fields['room'] = 'room';
|
||||
return $fields;
|
||||
}
|
||||
|
||||
|
||||
function extraFields()
|
||||
{
|
||||
$extra= parent::extraFields();
|
||||
$extra[] = 'trainer';
|
||||
return $extra;
|
||||
}
|
||||
|
||||
}
|
||||
56
customerapi/models/available/EventInterval.php
Normal file
56
customerapi/models/available/EventInterval.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace customerapi\models\available;
|
||||
|
||||
|
||||
use DateTime;
|
||||
|
||||
/**
|
||||
* Class DateIntervalHelper
|
||||
* @package customerapi\models\available
|
||||
* @property \DateTime $firstActiveDate
|
||||
* @property \DateTime $lastActiveDate
|
||||
* @property \DateTime $firstDisplayDate
|
||||
* @property \DateTime $lastDisplayDate
|
||||
*/
|
||||
class EventInterval
|
||||
{
|
||||
|
||||
public $countOfActiveDays = 14;
|
||||
public $daysToDisplay = 21;
|
||||
|
||||
|
||||
public $firstActiveDate;
|
||||
public $lastActiveDate;
|
||||
public $firstDisplayDate;
|
||||
public $lastDisplayDate;
|
||||
|
||||
private function __construct()
|
||||
{
|
||||
|
||||
$firstActiveDay = new DateTime();
|
||||
$firstActiveDay->setTime(0, 0);
|
||||
$this->firstActiveDate = $firstActiveDay;
|
||||
|
||||
$lastActiveDay = new DateTime();
|
||||
$lastActiveDay->setTime(0, 0);
|
||||
$lastActiveDay->modify('+' . $this->countOfActiveDays . ' day');
|
||||
$this->lastActiveDate = $lastActiveDay;
|
||||
|
||||
$firstDisplayDate = new DateTime();
|
||||
$firstDisplayDate->modify('this week');
|
||||
$firstDisplayDate->setTime(0, 0);
|
||||
$this->firstDisplayDate = $firstDisplayDate;
|
||||
|
||||
$lastDisplayDate = clone $firstDisplayDate;
|
||||
$lastDisplayDate->setTime(0, 0);
|
||||
$lastDisplayDate->modify('+' . $this->daysToDisplay . ' day');
|
||||
$this->lastDisplayDate = $lastDisplayDate;
|
||||
|
||||
}
|
||||
|
||||
public static function createInterval(){
|
||||
return new EventInterval();
|
||||
}
|
||||
}
|
||||
13
customerapi/models/available/EventRegistrationAvailable.php
Normal file
13
customerapi/models/available/EventRegistrationAvailable.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace customerapi\models\available;
|
||||
|
||||
|
||||
use common\models\EventRegistration;
|
||||
|
||||
class EventRegistrationAvailable extends EventRegistration
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
20
customerapi/models/available/EventTypeAvailable.php
Normal file
20
customerapi/models/available/EventTypeAvailable.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace customerapi\models\available;
|
||||
|
||||
|
||||
use common\models\EventType;
|
||||
|
||||
class EventTypeAvailable extends EventType
|
||||
{
|
||||
|
||||
function fields()
|
||||
{
|
||||
return [
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
19
customerapi/models/available/RoomAvailable.php
Normal file
19
customerapi/models/available/RoomAvailable.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace customerapi\models\available;
|
||||
|
||||
|
||||
use common\models\Room;
|
||||
|
||||
class RoomAvailable extends Room
|
||||
{
|
||||
function fields()
|
||||
{
|
||||
return [
|
||||
'id' => 'id',
|
||||
'name' => 'name',
|
||||
'seat_count' => 'seat_count'
|
||||
];
|
||||
}
|
||||
}
|
||||
20
customerapi/models/available/TrainerAvailable.php
Normal file
20
customerapi/models/available/TrainerAvailable.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace customerapi\models\available;
|
||||
|
||||
|
||||
use common\models\Trainer;
|
||||
|
||||
class TrainerAvailable extends Trainer
|
||||
{
|
||||
|
||||
public function fields()
|
||||
{
|
||||
return [
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user