kompass/modules/event-participants/Models/class-event.php

44 lines
1.0 KiB
PHP
Raw Permalink Normal View History

2024-05-27 16:59:30 +02:00
<?php
namespace Bdp\Modules\EventParticipants\Models;
use Bdp\Libs\CommonModel;
class Event extends CommonModel {
public static function loadById(int $event_id) : Event {
global $dbHandler;
$data = $dbHandler->readFromDb('kompass_veranstaltungen_index', ['id' => $event_id]);
$class = new Event();
$class->groups = ['participant' => [], 'volunteer' => [], 'other' => []];
foreach (get_object_vars($data[0]) as $key => $value) {
$class->$key = $value;
}
foreach (EventParticipant::list_for_event($event_id) as $participant) {
$class->groups[$participant->teilnahme][] = $participant;
}
foreach ($class->groups as $group) {
foreach ($group as $participant) {
if (!isset($class->tribes[$participant->stamm])) {
$class->tribes[$participant->stamm] = [];
}
$class->tribes[$participant->stamm][] = $participant;
}
}
return $class;
}
public function __construct() {
$this->_tablename = 'kompass_veranstaltungen_index';
$this->groups = [];
$this->tribes = [];
}
}