add Notes

This commit is contained in:
Leorne committed 2019-12-05 15:05:33 +03:00
1 parent 2279783ca8
commit f7177975a8
16 files changed
+521 -2

No files matched your search

+29
View File
@@ -0,0 +1,29 @@
<?php
namespace backend\modules\notes\models;
use common\models\FieldsValueNew;
class Note extends \common\models\Note
{
public function afterSave($insert, $changedAttributes)
{
$post = \Yii::$app->request->post('Note');
FieldsValueNew::deleteAll(['item_id' => $this->id, 'item_type' => FieldsValueNew::TYPE_NOTE]);
foreach ( $post['fields'] as $item) {
$fieldsValue = new FieldsValueNew();
$fieldsValue->field_id = $item['field_id'];
$fieldsValue->item_id = $this->id;
$fieldsValue->item_type = FieldsValueNew::TYPE_NOTE;
$fieldsValue->order = $item['order'];
$fieldsValue->value = $item['value'];
$fieldsValue->save();
}
parent::afterSave($insert, $changedAttributes);
}
}