|
@ -2,6 +2,7 @@ |
|
|
|
|
|
|
|
|
namespace backend\modules\goods\controllers; |
|
|
namespace backend\modules\goods\controllers; |
|
|
|
|
|
|
|
|
|
|
|
use backend\modules\goods\logic\goods\GoodsManager; |
|
|
use Yii; |
|
|
use Yii; |
|
|
use backend\modules\goods\models\ars\Attribute; |
|
|
use backend\modules\goods\models\ars\Attribute; |
|
|
use backend\modules\goods\models\searchs\AttributeSearch; |
|
|
use backend\modules\goods\models\searchs\AttributeSearch; |
|
@ -71,14 +72,7 @@ class AttributeController extends Controller |
|
|
$model->cat_id = 0; |
|
|
$model->cat_id = 0; |
|
|
|
|
|
|
|
|
if ($model->load(Yii::$app->request->post()) && $model->validate()) { |
|
|
if ($model->load(Yii::$app->request->post()) && $model->validate()) { |
|
|
$value = $model->value; |
|
|
|
|
|
$model->value = str_replace(',', ',', $value); |
|
|
|
|
|
$array = explode(',', $model->value); |
|
|
|
|
|
if (count($array) != count(array_unique($array))) { |
|
|
|
|
|
Yii::$app->getSession()->setFlash('error', '不能有相同的属性值'); |
|
|
|
|
|
return $this->render('create', ['model' => $model]); |
|
|
|
|
|
} |
|
|
|
|
|
if ($model->save()) { |
|
|
|
|
|
|
|
|
if (GoodsManager::updateAttribute($model)) { |
|
|
return $this->redirect(['index']); |
|
|
return $this->redirect(['index']); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -100,16 +94,9 @@ class AttributeController extends Controller |
|
|
$model = $this->findModel($id); |
|
|
$model = $this->findModel($id); |
|
|
|
|
|
|
|
|
if ($model->load(Yii::$app->request->post()) && $model->validate()) { |
|
|
if ($model->load(Yii::$app->request->post()) && $model->validate()) { |
|
|
$model->value = str_replace(',', ',', $model->value); |
|
|
|
|
|
$array = explode(',', $model->value); |
|
|
|
|
|
if (count($array) != count(array_unique($array))) { |
|
|
|
|
|
Yii::$app->getSession()->setFlash('error', '不能有相同的属性值'); |
|
|
|
|
|
return $this->render('create', ['model' => $model]); |
|
|
|
|
|
} |
|
|
|
|
|
if ($model->save()) { |
|
|
|
|
|
|
|
|
if (GoodsManager::updateAttribute($model)) { |
|
|
return $this->redirect(['index']); |
|
|
return $this->redirect(['index']); |
|
|
} |
|
|
} |
|
|
return $this->redirect('index'); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return $this->render('update', [ |
|
|
return $this->render('update', [ |
|
|