Browse Source

refactor:修改前端商品分类获取数据键值对方法

antshop
linyaostalker 5 years ago
parent
commit
938550f13a
  1. 16
      backend/modules/goods/models/ars/ShopCategory.php

16
backend/modules/goods/models/ars/ShopCategory.php

@ -2,9 +2,11 @@
namespace backend\modules\goods\models\ars;
use backend\modules\goods\logic\goods\GoodsManager;
use Yii;
use yii\behaviors\TimestampBehavior;
use backend\modules\file\models\ars\File;
use yii\db\ActiveQuery;
/**
* This is the model class for table "atg_shop_category".
@ -108,12 +110,20 @@ class ShopCategory extends \yii\db\ActiveRecord
/**
* @param int $ownId
* @return array
* @param int $needDefault
* @return array 数据键值对
* 数据键值对
*/
public static function modelColumn($ownId = 0)
public static function modelColumn($ownId = 0, $needDefault = 1)
{
return $column = self::find()->select(['name'])->where(['is_delete' => self::IS_DELETE_NO])->andWhere(['!=', 'id', $ownId])->indexBy('id')->column();
$query = self::find()->where(['is_delete' => self::IS_DELETE_NO]);
if ($ownId) {
$query->andWhere(['not in', 'id', GoodsManager::subShopCategoryId($ownId)]);
}
$data = $query->asArray()->all();
$data = GoodsManager::btree($data);
$data = GoodsManager::constructDropList($data, $needDefault);
return $data;
}
public function getIconFile()

Loading…
Cancel
Save