protected function updateSecSers() { SecSer::deleteAll(['ser' => $this->id]); if (is_array($this->sectionsId)) { foreach ($this->sectionsId as $id) { $secSer = new SecSer(); $secSer->ser = $this->id; $secSer->sec = $id; $secSer->save(); } } }