public function actionCreate()
{
$model = new News();
if ($model->load(Yii::$app->request->post())) {
$preview_img = UploadedFile::getInstance($model, 'icon_img');
if($preview_img){
$model->preview_img = $this->addPreviewImg($model, $preview_img);
}
$model->user_id = \Yii::$app->user->id;
$model->save();
Yii::$app->session->setFlash('success', "Новость добавлена");
return $this->redirect(['update', 'id' => $model->id]);
}
return $this->render('create', [
'model' => $model,
]);
}