* @license http://www.gnu.org/licenses/gpl-2.0.html GPL version 2 * @category Stud.IP * @since 3.5 */ class FachFachbereich extends ModuleManagementModel { protected static function configure($config = []) { $config['db_table'] = 'mvv_fach_inst'; $config['belongs_to']['fach'] = [ 'class_name' => Fach::class, 'foreign_key' => 'fach_id', 'assoc_func' => 'findCached', ]; $config['belongs_to']['fachbereich'] = [ 'class_name' => Fachbereich::class, 'foreign_key' => 'institut_id', 'assoc_func' => 'findCached', ]; parent::configure($config); } /** * Returns all asignments of institutes by given fach_id filteres by * optional parameter group. * * @param string $modul_id The id of the Fach the institutes are assigned to * @param string $group Optional group * @return array Array of objects */ public static function findByFach($fach_id) { $params = [$fach_id]; $ret = []; $fach_insts = parent::getEnrichedByQuery('SELECT mfi.* ' . 'FROM mvv_fach_inst mfi ' . 'WHERE mfi.fach_id = ? ', $params); foreach ($fach_insts as $fach_inst) { $ret[$fach_inst->institut_id] = $fach_inst; } return $ret; } public function validate() { $ret = parent::validate(); if ($this->fachbereich->isNew()) { throw new Exception(_('Unbekannte Einrichtung')); } return $ret; } }