| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- <?php
- /**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
- namespace app\modules\admin\models;
- use yii\base\Model;
- class IntelligentMatchForm extends Model
- {
- public $store_id = 1;
- public $parent_id;
- public $sort;
- public $cat_name;
- public $is_show;
- public $model;
- /**
- * @return array
- */
- public function rules()
- {
- return [
- [['parent_id', 'store_id', 'sort'], 'integer'],
- [['cat_name'], 'string', 'max' => 60],
- [['sort'], 'default', 'value' => 100],
- [['is_show'], 'default', 'value' => 1],
- [['is_delete'], 'default', 'value' => 0]
- ];
- }
- /**
- * 保存分类
- * @return array
- */
- public function save()
- {
- $this->model->parent_id = $this->parent_id;
- $this->model->is_show = $this->is_show;
- if ($this->is_show == 0) {
- // 产品分类隐藏同时下架该分类下所有商品
- /*$goods_ids = GoodsCat::find()->where(['is_delete' => 0, 'store_id' => get_store_id(),
- 'cat_id' => post_params('id')])->select('goods_id')->asArray()->all();
- Goods::updateAll(['status' => Goods::STATUS_DISABLE],['in', 'id', array_column($goods_ids, 'goods_id')]);*/
- }
- $this->model->cat_name = $this->cat_name;
- $this->model->sort = $this->sort;
- $this->model->store_id = $this->store_id;
- if ($this->model->save()) {
- return [
- 'code' => 0,
- 'msg' => '提交成功'
- ];
- } else {
- return [
- 'code' => 0,
- 'msg' => '保存失败'
- ];
- }
- }
- }
|