Basic implementation event signup
This commit is contained in:
45
modules/event-participants/Models/class-event.php
Normal file
45
modules/event-participants/Models/class-event.php
Normal file
@ -0,0 +1,45 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
|
||||
#echo '<pre>';print_r($class);die();
|
||||
return $class;
|
||||
|
||||
}
|
||||
|
||||
public function __construct() {
|
||||
$this->_tablename = 'kompass_veranstaltungen_index';
|
||||
$this->groups = [];
|
||||
$this->tribes = [];
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user