diff options
| author | Jan-Hendrik Willms <tleilax+studip@gmail.com> | 2022-05-11 08:30:37 +0000 |
|---|---|---|
| committer | Jan-Hendrik Willms <tleilax+studip@gmail.com> | 2022-05-11 08:30:37 +0000 |
| commit | 5866bdf1497623253096c1e39fb8d853c1438634 (patch) | |
| tree | 1c29411180742245ddb0974385170d83011181e2 /lib/models/Degree.class.php | |
| parent | 04b5e6ec7ca39031f0c50289fb2892d2dc0934c1 (diff) | |
unify class definition in relations of simpleormap models, fixes #979
Closes #979
Merge request studip/studip!564
Diffstat (limited to 'lib/models/Degree.class.php')
| -rw-r--r-- | lib/models/Degree.class.php | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/lib/models/Degree.class.php b/lib/models/Degree.class.php index 502e9f7..04c4da6 100644 --- a/lib/models/Degree.class.php +++ b/lib/models/Degree.class.php @@ -25,20 +25,20 @@ class Degree extends SimpleORMap protected static function configure($config = []) { $config['db_table'] = 'abschluss'; - + $config['has_and_belongs_to_many']['professions'] = [ - 'class_name' => 'StudyCourse', + 'class_name' => StudyCourse::class, 'thru_table' => 'user_studiengang', 'thru_key' => 'abschluss_id', 'thru_assoc_key' => 'fach_id', 'order_by' => 'GROUP BY fach_id ORDER BY name' ]; - + $config['additional_fields']['count_user']['get'] = 'countUser'; - + parent::configure($config); } - + public function countUser() { $stmt = DBManager::get()->prepare('SELECT COUNT(DISTINCT user_id) ' @@ -46,7 +46,7 @@ class Degree extends SimpleORMap $stmt->execute([$this->id]); return $stmt->fetchColumn(); } - + public function countUserByStudycourse($studycourse_id) { $stmt = DBManager::get()->prepare('SELECT COUNT(DISTINCT user_id) ' @@ -55,7 +55,7 @@ class Degree extends SimpleORMap $stmt->execute([$studycourse_id, $this->id]); return $stmt->fetchColumn(); } - + public function store() { if ($this->isNew() || $this->isDirty()) { @@ -64,8 +64,8 @@ class Degree extends SimpleORMap $this->author_id = $GLOBALS['user']->id; } } - + return parent::store(); } - + } |
