public function save() { $criterionPrioritization = new CriterionPrioritization(); $criterionPrioritization->criterion_head_id = is_object($this->head) ? $this->head->id : $this->head; $criterionPrioritization->criterion_tail_id = is_object($this->tail) ? $this->tail->id : $this->tail; $criterionPrioritization->rating_method = 'pairwise comparison'; $criterionPrioritization->response_id = $this->response_id; $criterionPrioritization->score = $this->values; $criterionPrioritization->save(); }
public function save($values, $method, $response_id) { foreach ($values as $id => $score) { $criterionPrioritization = CriterionPrioritizationTable::getInstance()->getOneForSave($response_id, $id); if (!$criterionPrioritization) { $criterionPrioritization = new CriterionPrioritization(); } $criterionPrioritization->criterion_head_id = $id; $criterionPrioritization->rating_method = $method; $criterionPrioritization->response_id = $response_id; $criterionPrioritization->score = $score; $criterionPrioritization->save(); } }