|
|
@ -85,7 +85,11 @@ class GoodsController extends Controller |
|
|
|
$file_id_str = $model->imageId; |
|
|
|
$model->save(); |
|
|
|
$goods_manager = new GoodsManager(); |
|
|
|
$goods_manager->saveFile($file_id_str, $model); |
|
|
|
$save_file_res = $goods_manager->saveFile(explode($file_id_str), $model); |
|
|
|
if($save_file_res['status']){ |
|
|
|
$model->image = $save_file_res['first_file_id']; |
|
|
|
$model->save(); |
|
|
|
} |
|
|
|
return $this->redirect('index'); |
|
|
|
} |
|
|
|
|
|
|
@ -105,8 +109,17 @@ class GoodsController extends Controller |
|
|
|
{ |
|
|
|
$model = $this->findModel($id); |
|
|
|
$model->imageId = $model->image; |
|
|
|
$old_id_arr = $model->image; |
|
|
|
|
|
|
|
if ($model->load(Yii::$app->request->post()) && $model->save()) { |
|
|
|
if ($model->load(Yii::$app->request->post())) { |
|
|
|
$file_id_str = $model->imageId; |
|
|
|
$model->save(); |
|
|
|
$goods_manager = new GoodsManager(); |
|
|
|
$save_file_res = $goods_manager->saveFile(explode($file_id_str), $model, $old_id_arr); |
|
|
|
if($save_file_res['status']){ |
|
|
|
$model->image = $save_file_res['first_file_id']; |
|
|
|
$model->save(); |
|
|
|
} |
|
|
|
return $this->redirect('index'); |
|
|
|
} |
|
|
|
|
|
|
@ -183,9 +196,9 @@ class GoodsController extends Controller |
|
|
|
$model->user_id = Yii::$app->user->identity->id; |
|
|
|
$model->name = $file_name; |
|
|
|
$file_manager = new \backend\logic\file\FileManager(); |
|
|
|
$type = $file_manager->searchType(\backend\logic\file\FileManager::$extension, pathinfo($data['path'])['extension']); |
|
|
|
if ($type) { |
|
|
|
$model->type = $type; |
|
|
|
$type_res = $file_manager->searchType(\backend\logic\file\FileManager::$extension, pathinfo($data['path'])['extension']); |
|
|
|
if ($type_res['status']) { |
|
|
|
$model->type = $type_res['type']; |
|
|
|
} |
|
|
|
$model->alias = $data['alias']; |
|
|
|
$model->path = $data['path']; |
|
|
|