'{attribute}不能为空'], ['name', 'unique','targetClass' => 'common\models\Brand','on'=>'add','message'=>'该品牌名称已经存在', 'filter'=>function($query){ return $query->andWhere(['del'=>$this->setDel]); }], ['name','string','max'=>255], ['sort','number','max'=>10000], ]; } public function attributeLabels() { return [ 'name'=>'品牌名称', 'country'=>'所属国家', ]; } public function Total($input) { $query = self::find(); $query->andWhere(['del'=>$this->setDel]); if(!empty($input['name'])) { $query->andWhere(['like','name',$input['name']]); } return $query->count(); } /* * 后台 - 品牌页面数据 */ public function GetList($input) { $query = self::find(); $query->andWhere(['del'=>$this->setDel]); if(!empty($input['name'])) { $query->andWhere(['like','name',$input['name']]); } if(!empty($input['page'])) { $query->limit = $input['limit']; $query->offset = ($input['page']-1 )* $input['limit']; } $query->orderBy(['pfg_brand.sort'=>SORT_DESC,'pfg_brand.id'=>SORT_DESC]); return $query->asArray()->all(); } /* * PC首页品牌馆 */ public function getPcBrand($limit = null) { $query = self::find(); $query->select(['pfg_brand.id','pfg_brand.name','pfg_brand.img','pfg_category_city.city_name']); $query->andWhere(['pfg_brand.is_show'=>1]); $query->leftJoin('pfg_category_city','pfg_category_city.id=pfg_brand.country'); $query->orderBy(['pfg_brand.sort'=>SORT_DESC,'pfg_brand.id'=>SORT_DESC]); $query->limit = $limit; return $query->asArray()->all(); } /* * PC首页品牌馆 */ public function getPcSearchBrand() { $query = self::find(); $query->select(['id','name']); $query->andWhere(['is_show'=>1]); $query->orderBy(['sort'=>SORT_DESC,'id'=>SORT_DESC]); return $query->asArray()->all(); } }