| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- <?php
- /**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
- namespace app\models;
- use Yii;
- use yii\db\ActiveRecord;
- use yii\behaviors\TimestampBehavior;
- /**
- * This is the model class for table "{{%user_coupon}}".
- *
- * @property integer $id
- * @property integer $store_id
- * @property string $label_name
- * @property integer $sort
- * @property integer $status
- * @property integer $is_delete
- * @property integer $created_at
- * @property integer $updated_at
- */
- class UserLabel extends \yii\db\ActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%user_label}}';
- }
- const STATUS_OPEN = 1;
- const STATUS_CLOSE = 0;
- public function behaviors()
- {
- return [
- [
- 'class' => 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();
- }
- }
|