public function replace_section($old_section_id, $new_section_id) { $sections = $this->sections; $key = array_search($old_section_id, $sections); $sections[$key] = $new_section_id; $this->sections = $sections; $this->save(); ProjectSection::change_times_used($old_section_id, -1); ProjectSection::change_times_used($new_section_id, 1); }