96 lines
3.4 KiB
PHP
96 lines
3.4 KiB
PHP
<?php
|
|
|
|
class RsvTimetableCapacity {
|
|
public int|null $id;
|
|
|
|
public int $timetable_id;
|
|
|
|
public int $capacity;
|
|
|
|
public int $min_lead_time_minutes;
|
|
|
|
public DateTime $date;
|
|
public int $start_time;
|
|
public int $end_time;
|
|
|
|
public int $repeat_period_in_days;
|
|
public int $repeat_times;
|
|
|
|
public bool $requires_confirmation;
|
|
|
|
public static function schema(): array {
|
|
return [
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'id' => ['type' => 'integer', 'readonly' => true],
|
|
'timetable_id' => ['type' => 'integer', 'readonly' => true],
|
|
'capacity' => ['type' => 'integer', 'required' => true, 'minimum' => 1],
|
|
'min_lead_time_minutes' => ['type' => 'integer', 'required' => true, 'minimum' => 0],
|
|
'date' => ['type' => 'string', 'required' => true, 'format' => 'date'],
|
|
'start_time' => ['type' => 'integer', 'required' => true, 'minimum' => 0],
|
|
'end_time' => ['type' => 'integer', 'required' => true, 'minimum' => 0],
|
|
'repeat_period_in_days' => ['type' => 'integer', 'required' => true, 'minimum' => 0],
|
|
'repeat_times' => ['type' => 'integer', 'required' => true, 'minimum' => 0],
|
|
'requires_confirmation' => ['type' => 'boolean'],
|
|
],
|
|
];
|
|
}
|
|
|
|
public static function from_array(array $data): self {
|
|
return new self(
|
|
$data['id'],
|
|
$data['timetable_id'],
|
|
$data['capacity'],
|
|
$data['min_lead_time_minutes'],
|
|
new DateTime($data['date']),
|
|
$data['start_time'],
|
|
$data['end_time'],
|
|
$data['repeat_period_in_days'],
|
|
$data['repeat_times'],
|
|
$data['requires_confirmation'] ?? false
|
|
);
|
|
}
|
|
|
|
public function __construct(
|
|
int|null $id,
|
|
int $timetable_id,
|
|
int $capacity,
|
|
int $min_lead_time_minutes,
|
|
DateTime $date,
|
|
int $start_time,
|
|
int $end_time,
|
|
int|null $repeat_period_in_days,
|
|
int|null $repeat_times,
|
|
bool $requires_confirmation
|
|
) {
|
|
$this->id = $id;
|
|
$this->timetable_id = $timetable_id;
|
|
$this->capacity = $capacity;
|
|
$this->min_lead_time_minutes = $min_lead_time_minutes;
|
|
$this->date = $date;
|
|
$this->start_time = $start_time;
|
|
$this->end_time = $end_time;
|
|
$this->repeat_period_in_days = $repeat_period_in_days;
|
|
$this->repeat_times = $repeat_times;
|
|
$this->requires_confirmation = $requires_confirmation;
|
|
// $this->repeat_times = $data['repeat_times'];
|
|
|
|
// $this->requires_confirmation = $data['requires_confirmation'] ?? false;
|
|
}
|
|
|
|
public function to_array(): array {
|
|
return [
|
|
'id' => $this->id,
|
|
'timetable_id' => $this->timetable_id,
|
|
'capacity' => $this->capacity,
|
|
'min_lead_time_minutes' => $this->min_lead_time_minutes,
|
|
'date' => $this->date->format('Y-m-d'),
|
|
'start_time' => $this->start_time,
|
|
'end_time' => $this->end_time,
|
|
'repeat_period_in_days' => $this->repeat_period_in_days,
|
|
'repeat_times' => $this->repeat_times,
|
|
'requires_confirmation' => $this->requires_confirmation,
|
|
];
|
|
}
|
|
}
|