| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- <?php
- /**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
- namespace app\models;
- use app\models\common\admin\log\CommonActionLog;
- use Yii;
- use yii\behaviors\TimestampBehavior;
- /**
- * This is the model class for table "{{%goods_cat}}".
- *
- * @property integer $id
- * @property integer $user_id
- * @property string $goods_brand_id
- * @property string $created_at
- * @property string $updated_at
- */
- class GoodsBrandSubscribeLog extends \yii\db\ActiveRecord
- {
- /**
- * @inheritdoc
- */
- public static function tableName()
- {
- return '{{%goods_brand_subscribe_log}}';
- }
- /**
- * @inheritdoc
- */
- public function rules()
- {
- return [
- [['id', 'user_id', 'goods_brand_id'], 'integer'],
- [['created_at', 'updated_at'], 'string'],
- ];
- }
- public function behaviors()
- {
- return [
- [
- 'class' => TimestampBehavior::class,
- ]
- ];
- }
- /**
- * @inheritdoc
- */
- public function attributeLabels()
- {
- return [
- 'id' => '主键',
- 'user_id' => '用户ID',
- 'goods_brand_id' => '品牌ID',
- 'created_at' => '添加时间',
- 'updated_at' => '',
- ];
- }
- // public function afterSave($insert, $changedAttributes)
- // {
- /*$data = $insert ? json_encode($this->attributes) : json_encode($changedAttributes);
- CommonActionLog::storeActionLog('', $insert, $this->is_delete, $data, $this->id);*/
- // }
- public static function getUserSubscribeLog($user_id) {
- return self::find()->alias('s')->leftJoin(['b' => GoodsBrand::tableName()], 's.goods_brand_id = b.id')
- ->where(['s.user_id' => $user_id, 'b.is_delete' => 0, 'b.is_show' => 1])->select('s.goods_brand_id')
- ->orderBy('s.id DESC')->column();
- }
- public static function getBrandList($brand_id) {
- return self::find()->where(['goods_brand_id' => $brand_id])->select('id')->column();
- }
- public static function isSubscribe($user_id, $brand_id) {
- return self::findOne(['goods_brand_id' => $brand_id, 'user_id' => $user_id]);
- }
- }
|