diff --git a/vendor/antgoods/goods/src/controllers/CategoryController.php b/vendor/antgoods/goods/src/controllers/CategoryController.php index 64017dc..1d96800 100644 --- a/vendor/antgoods/goods/src/controllers/CategoryController.php +++ b/vendor/antgoods/goods/src/controllers/CategoryController.php @@ -105,7 +105,10 @@ class CategoryController extends Controller */ public function actionDelete($id) { - $this->findModel($id)->delete(); + $model = $this->findModel($id); + + $model->is_delete = Category::IS_DELETE_YES; + $model->save(); return $this->redirect(['index']); } diff --git a/vendor/antgoods/goods/src/models/ars/Category.php b/vendor/antgoods/goods/src/models/ars/Category.php index 9fe01df..212def5 100644 --- a/vendor/antgoods/goods/src/models/ars/Category.php +++ b/vendor/antgoods/goods/src/models/ars/Category.php @@ -22,6 +22,18 @@ use yii\behaviors\TimestampBehavior; */ class Category extends \yii\db\ActiveRecord { + //是否显示is_show + const IS_SHOW_DISPLAY = 0;//显示 + const IS_SHOW_HIDE = 1;//隐藏 + //是否删除is_delete + const IS_DELETE_NO = 0;//未删除 + const IS_DELETE_YES = 1;//已删除 + + public static $isShow = [ + self::IS_SHOW_DISPLAY => '显示', + self::IS_SHOW_HIDE => '隐藏' + ]; + /** * {@inheritdoc} */ @@ -56,7 +68,7 @@ class Category extends \yii\db\ActiveRecord 'sort_order' => '排序', 'icon_type' => '图标类型', 'icon' => '图标', - 'is_show' => '是否显示,1为不显示', + 'is_show' => '是否显示', 'is_delete' => '是否删除,1为已删除', 'created_at' => '创建时间', 'updated_at' => '更新时间', diff --git a/vendor/antgoods/goods/src/models/searchs/CategorySearch.php b/vendor/antgoods/goods/src/models/searchs/CategorySearch.php index 63ad3f0..7ed7c4f 100644 --- a/vendor/antgoods/goods/src/models/searchs/CategorySearch.php +++ b/vendor/antgoods/goods/src/models/searchs/CategorySearch.php @@ -121,6 +121,7 @@ class CategorySearch extends Category * 条件筛选 */ private function filter($query, $dataProvider){ + $query->andFilterWhere(['is_delete' => 0]); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); diff --git a/vendor/antgoods/goods/src/views/category/_form.php b/vendor/antgoods/goods/src/views/category/_form.php index d154648..4badc99 100644 --- a/vendor/antgoods/goods/src/views/category/_form.php +++ b/vendor/antgoods/goods/src/views/category/_form.php @@ -2,6 +2,7 @@ use yii\helpers\Html; use yii\widgets\ActiveForm; +use blobt\widgets\Icheck; /* @var $this yii\web\View */ /* @var $model antgoods\goods\models\ars\Category */ @@ -22,9 +23,7 @@ use yii\widgets\ActiveForm; field($model, 'icon')->textInput(['maxlength' => true]) ?> - field($model, 'is_show')->textInput() ?> - - field($model, 'is_delete')->textInput() ?> + field($model, 'is_show')->widget(Icheck::className(), ["items" => $model::$isShow, 'type' => "radio"]) ?>
'btn btn-success']) ?>