Commit b7136601 authored by Shakarim Sapa's avatar Shakarim Sapa

- Добавлено сохранение переданных файлов в связанной модели

parent ac493522
......@@ -50,6 +50,11 @@ class AnalyticsSchoolLesson extends \common\components\ActiveRecordModel
];
}
/**
* @param null $attributeNames
* @param bool $clearErrors
* @return bool
*/
public function validate($attributeNames = null, $clearErrors = true){
if (!parent::validate($attributeNames = null, $clearErrors = true))
return false;
......@@ -69,6 +74,26 @@ class AnalyticsSchoolLesson extends \common\components\ActiveRecordModel
return true;
}
/**
* @param bool $insert
* @param array $changedAttributes
* @return bool|void
*/
public function afterSave($insert, $changedAttributes){
parent::afterSave($insert, $changedAttributes);
$files = UploadedFile::getInstances($this, 'file');
foreach($files as $index=>$file) {
if (isset($this->filename[$index])) {
$model = new AnalyticsSchoolLessonFile();
$model->lesson_id = $this->id;
$model->title = $this->filename[$index];
$model->document = $file;
$model->save();
}
}
}
/**
* @inheritdoc
*/
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment