public function actionUpdate($id)
{
$model = $this->findModel($id);
$image = $model->file;
if ($model->load(Yii::$app->request->post())) {
$model->file = UploadedFile::getInstance($model, 'file');
if(isset($model->file)){
$model->file->saveAs('attachment/'.$model->id_zakaz.'.'.$model->file->extension);
$model->img = $model->id_zakaz.'.'.$model->file->extension;}
$model->save();
if (empty($model->file) && $image) {
$model->file = $image;
$model->save();
}
return $this->redirect(['view', 'id' => $model->id_zakaz]);
} else {
return $this->render('update', [
'model' => $model,
]);
}
}