В папку картинка загружается, а вот в БД запись не идет Выдает ошибку
Код: Выделить всё
SQLSTATE[HY000]: General error: 1364 Field 'img' doesn't have a default value
Уже не знаю что делать, что не так ? вот экшен
Код: Выделить всё
public function actionCreate()
{
$model = new Item();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
$imageName = time();
$model->image = UploadedFile::getInstance($model, 'image');
if(!empty($model->image))
{
$model->image->saveAs('../uploads/blog_'.$imageName.'.'.$model->image->extension);
$model->img = '../uploads/blog_'.$imageName.'.'.$model->image->extension;
$model->save();
}
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('create', [
'model' => $model,
]);
}
}
Вот попытка сделать запись
Код: Выделить всё
$model->img = '../uploads/blog_'.$imageName.'.'.$model->image->extension;