TimestampBehavior::class, 'attributes' => [ ActiveRecord::EVENT_BEFORE_INSERT => ['updated_at', 'created_at'], ActiveRecord::EVENT_BEFORE_UPDATE => 'updated_at' ] ] ]; } /** * {@inheritdoc} */ public function rules() { return [ [['id', 'store_id', 'sort', 'status', 'is_delete'], 'integer'], [['label_name'], 'string'], [['created_at', 'updated_at'], 'safe'], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => '', 'store_id' => 'Store Id', 'label_name' => '标签名称', 'sort' => '排序', 'status' => '状态:0=关闭;1=开启;', 'is_delete' => 'Is Delete', 'created_at' => '', 'updated_at' => '', ]; } //获取无页码标签 public static function getList($store_id, $label_name = '') { $query = self::find()->where(['store_id' => $store_id, 'is_delete' => 0, 'status' => self::STATUS_OPEN])->orderBy('sort DESC') ->select('id, label_name'); if (!empty($label_name)) { $query->andWhere(['LIKE', 'label_name', $label_name]); } return $query->asArray()->all(); } //获取标签 public static function getLabel($store_id, $id) { return self::findOne(['store_id' => $store_id, 'is_delete' => 0, 'id' => $id, 'status' => self::STATUS_OPEN]); } public static function getLabelNames($store_id, $ids){ return self::find()->where(['store_id' => $store_id, 'is_delete' => 0, 'id' => explode(',',$ids), 'status' => self::STATUS_OPEN])->select('label_name')->asArray()->column(); } }