public function setTypeAttributes($attributes)
{
TypeAttribute::model()->deleteAllByAttributes(['type_id' => $this->id]);
if (is_array($attributes)) {
foreach ($attributes as $attribute_id) {
$typeAttribute = new TypeAttribute();
$typeAttribute->type_id = $this->id;
$typeAttribute->attribute_id = $attribute_id;
$typeAttribute->save();
}
}
}