|
@ -10,6 +10,7 @@ use backend\modules\goods\models\searchs\CategorySearch; |
|
|
use yii\web\Controller; |
|
|
use yii\web\Controller; |
|
|
use yii\web\NotFoundHttpException; |
|
|
use yii\web\NotFoundHttpException; |
|
|
use yii\filters\VerbFilter; |
|
|
use yii\filters\VerbFilter; |
|
|
|
|
|
use backend\modules\file\logic\file\FileManager; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* CategoryController implements the CRUD actions for Category model. |
|
|
* CategoryController implements the CRUD actions for Category model. |
|
@ -82,18 +83,13 @@ class CategoryController extends Controller |
|
|
$model->sort_order = 0; |
|
|
$model->sort_order = 0; |
|
|
|
|
|
|
|
|
if ($model->load(Yii::$app->request->post()) && $model->validate()) { |
|
|
if ($model->load(Yii::$app->request->post()) && $model->validate()) { |
|
|
|
|
|
|
|
|
//类目图片上传保存处理
|
|
|
//类目图片上传保存处理
|
|
|
$icon_image_id_str = $model->iconImageId; |
|
|
|
|
|
$model->save(); |
|
|
|
|
|
$save_icon_image_res = GoodsManager::saveFile(explode(',', $icon_image_id_str), $model, [], File::OWN_TYPE_CATEGORY_ICON); |
|
|
|
|
|
if($save_icon_image_res['status']){ |
|
|
|
|
|
$model->icon = $save_icon_image_res['first_file_id']; |
|
|
|
|
|
$model->save(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
$res = FileManager::saveFileInModel($model, 'iconImageId', '', File::OWN_TYPE_CATEGORY_ICON, 'icon'); |
|
|
|
|
|
|
|
|
|
|
|
if ($res) { |
|
|
return $this->redirect('index'); |
|
|
return $this->redirect('index'); |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return $this->render('create', [ |
|
|
return $this->render('create', [ |
|
|
'model' => $model, |
|
|
'model' => $model, |
|
@ -115,18 +111,13 @@ class CategoryController extends Controller |
|
|
$icon_image_old_id_arr = $model->icon; |
|
|
$icon_image_old_id_arr = $model->icon; |
|
|
|
|
|
|
|
|
if ($model->load(Yii::$app->request->post()) && $model->validate()) { |
|
|
if ($model->load(Yii::$app->request->post()) && $model->validate()) { |
|
|
|
|
|
|
|
|
//类目图片上传保存处理
|
|
|
//类目图片上传保存处理
|
|
|
$icon_image_id_str = $model->iconImageId; |
|
|
|
|
|
$model->save(); |
|
|
|
|
|
$save_icon_image_res = GoodsManager::saveFile(explode(',', $icon_image_id_str), $model, explode(',', $icon_image_old_id_arr), File::OWN_TYPE_CATEGORY_ICON); |
|
|
|
|
|
if($save_icon_image_res['status'] && $save_icon_image_res['first_file_id'] !== 0){ |
|
|
|
|
|
$model->icon = $save_icon_image_res['first_file_id']; |
|
|
|
|
|
$model->save(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
$res = FileManager::saveFileInModel($model, 'iconImageId', $icon_image_old_id_arr, File::OWN_TYPE_CATEGORY_ICON, 'icon'); |
|
|
|
|
|
|
|
|
|
|
|
if ($res) { |
|
|
return $this->redirect('index'); |
|
|
return $this->redirect('index'); |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return $this->render('update', [ |
|
|
return $this->render('update', [ |
|
|
'model' => $model, |
|
|
'model' => $model, |
|
|