41 lines
1013 B
PHP
41 lines
1013 B
PHP
|
<?php
|
||
|
namespace Bdp\Libs;
|
||
|
|
||
|
use Bdp\Modules\EventParticipants\Controllers\MainController;
|
||
|
use Bdp\Modules\EventParticipants\Models\EventGroup;
|
||
|
|
||
|
class CommonModel extends \stdClass {
|
||
|
protected string $_tablename;
|
||
|
|
||
|
public static function load_by_id(string $table_name, int $object_id) {
|
||
|
global $dbHandler;
|
||
|
|
||
|
$data = $dbHandler->readFromDb($table_name, ['id' => $object_id]);
|
||
|
$class = new CommonModel();
|
||
|
|
||
|
foreach (get_object_vars($data[0]) as $key => $value) {
|
||
|
$class->$key = $value;
|
||
|
}
|
||
|
|
||
|
return $class;
|
||
|
}
|
||
|
|
||
|
public function delete() {
|
||
|
global $dbHandler;
|
||
|
|
||
|
}
|
||
|
public function is_fullaged() : bool {
|
||
|
return kompass_is_fullaged($this->geburtsdatum);
|
||
|
}
|
||
|
|
||
|
public function get_age() {
|
||
|
$obj_birthday = \DateTime::createFromFormat('Y-m-d', $this->geburtsdatum);
|
||
|
$today = new \DateTime();
|
||
|
$compare = date_diff($today, $obj_birthday);
|
||
|
return $compare->y;
|
||
|
}
|
||
|
|
||
|
public function get_group() : CommonModel {
|
||
|
return EventGroup::load_by_id(MainController::KOMPASS_EVENTS_GROUPS, $this->gruppe_id);
|
||
|
}
|
||
|
}
|