Course::class, 'foreign_key' => 'range_id', ]; $config['belongs_to']['institute'] = [ 'class_name' => Institute::class, 'foreign_key' => 'range_id', ]; parent::configure($config); } /** * Specialized getValue that returns the course default for edit_restricted. * * @param string $field Field to get the value for * @return mixed */ public function getValue($field) { if ($field !== 'edit_restricted' || !$this->isNew() || !$this->range_id) { return parent::getValue($field); } return CourseConfig::get($this->range_id)->WIKI_COURSE_EDIT_RESTRICTED; } /** * Returns whether the current settings are the default settings (db-wise * and from course setting). * * @return boolean */ public function isDefault() { return $this->read_restricted === $this->getDefaultValue('read_restricted') && $this->edit_restricted === CourseConfig::get($this->range_id)->WIKI_COURSE_EDIT_RESTRICTED; } }