| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- <?php
- namespace addons\OperationCenter\common\models;
- use Yii;
- /**
- * This is the model class for table "{{%addons_operation_center_setting_log}}".
- *
- * @property int $id
- * @property int $mall_id
- * @property string|null $after_setting
- * @property string|null $before_setting
- * @property int|null $deleted_at
- * @property int|null $updated_at
- * @property int|null $created_at
- */
- class SettingLog extends BaseActiveRecord
- {
- /**
- * @var array
- */
- protected $json_keys = [
- 'after_setting', 'before_setting'
- ];
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%addons_operation_center_setting_log}}';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['mall_id'], 'required'],
- [['mall_id', 'deleted_at', 'updated_at', 'created_at'], 'integer'],
- [['after_setting', 'before_setting'], 'string'],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'mall_id' => 'Mall ID',
- 'after_setting' => 'After Setting',
- 'before_setting' => 'Before Setting',
- 'deleted_at' => 'Deleted At',
- 'updated_at' => 'Updated At',
- 'created_at' => 'Created At',
- ];
- }
- /**
- * 添加设置日志
- *
- * @param integer $mall_id
- * @param array $before_setting
- * @param array $after_setting
- * @return boolean
- */
- public static function addSettingLog(
- int $mall_id, array $before_setting, array $after_setting
- )
- {
- $data = compact('mall_id', 'before_setting', 'after_setting');
- $model = new static();
- $data = $model->jsonEncode($data);
- $model->load($data, '');
- return $model->save();
- }
- /**
- * 获取最后设置的ID
- *
- * @param integer $mall_id
- * @return int
- */
- public static function getLastSettingId(int $mall_id)
- {
- return static::find()
- ->select('id')
- ->andWhere(['mall_id' => $mall_id])
- ->orderBy('id desc')
- ->scalar();
- }
- }
|