почему не сохраняются записи в бд? Yii2. Дело не в пути.
public function actionCreate()
{
$model = new Product();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
$model->gallery = UploadedFile::getInstances($model, 'gallery');
$model->uploadGallery();
$model->file = UploadedFile::getInstance($model, 'file');
if ($model->file){
$model->upload();
}
return $this->redirect(['view', 'id' => $model->id]);
}
return $this->render('create', [
'model' => $model,
]);
}
public function upload(){
if($this->validate()){
$path ='upload/store/' . $this->file->baseName . '.' . $this->file->extension;
$this->file->saveAs($path,false);
$this->attachImage($path);
@unlink($path);
return true;
} else {
return false;
}
}
public function uploadGallery()
{
if ($this->validate()) {
foreach($this->gallery as $files){
$path ='upload/store/' . $files->baseName.'.'.$files->extension;
$files->saveAs($path,false);
$this->attachImage($path);
@unlink($path);
}
return true;
} else {
return false;
};
}