initial
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
class RsvReservation {
|
||||
public ?int $id;
|
||||
|
||||
public int $form_submit_id;
|
||||
|
||||
public bool|null $is_confirmed;
|
||||
|
||||
public array $timetable_reservations;
|
||||
|
||||
public static function schema(): array {
|
||||
return [
|
||||
'type' => 'object',
|
||||
'properties' => [
|
||||
'id' => ['type' => 'integer', 'readonly' => true],
|
||||
'form_submit_id' => ['type' => 'integer', 'readonly' => true],
|
||||
'is_confirmed' => ['type' => 'boolean', 'readonly' => true],
|
||||
'timetable_reservations' => [
|
||||
'type' => 'array',
|
||||
'required' => true,
|
||||
'items' => RsvTimetableReservation::schema(),
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public static function from_array(array $data) : self {
|
||||
return new self(
|
||||
intval($data['id'] ?? null),
|
||||
intval($data['form_submit_id'] ?? null),
|
||||
$data['is_confirmed'] ?? null,
|
||||
array_map(fn($t) =>
|
||||
new RsvTimetableReservation(null, $data['timetable_id'], $t['start'], $t['end']),
|
||||
$data['timetable_reservations'] ?? [])
|
||||
);
|
||||
}
|
||||
|
||||
public function __construct(?int $id, int $form_submit_id, bool|null $is_confirmed, array $timetable_reservations)
|
||||
{
|
||||
$this->id = $id;
|
||||
$this->form_submit_id = $form_submit_id;
|
||||
$this->is_confirmed = $is_confirmed;
|
||||
$this->timetable_reservations = $timetable_reservations;
|
||||
}
|
||||
|
||||
public function to_array() {
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'form_submit_id' => $this->form_submit_id,
|
||||
'is_confirmed' => $this->is_confirmed,
|
||||
// 'timetable_reservations' => $this->timetable_reservations,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user