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(); } } }
/** * @return \yii\db\ActiveQuery */ public function getSecSers() { return $this->hasMany(SecSer::className(), ['sec' => 'id']); }