| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- <?php
- namespace common\models\common;
- use common\enums\StatusEnum;
- use RuntimeException;
- use Yii;
- /**
- * This is the model class for table "qimall_mpwx_plugins".
- *
- * @property int $id 主键
- * @property string $addons_name 插件标识
- * @property string $name 插件名称
- * @property string|null $plugins 插件安装配置
- * @property int $status 状态【1启用 0禁用 -1删除】
- * @property int|null $created_at 创建时间
- * @property int|null $updated_at 修改时间
- */
- class MpwxPlugins extends \common\models\base\BaseActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return 'qimall_mpwx_plugins';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['status', 'created_at', 'updated_at'], 'integer'],
- [['addons_name', 'name'], 'string', 'max' => 100],
- [['plugins'], 'string', 'max' => 255],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'addons_name' => 'Addons Name',
- 'name' => 'Name',
- 'plugins' => 'Plugins',
- 'status' => 'Status',
- 'created_at' => 'Created At',
- 'updated_at' => 'Updated At',
- ];
- }
- /**
- * 保存数据,如果存在则更新
- *
- * @param array $params
- *
- * @return object|boolean
- */
- public static function setData(array $params)
- {
- try {
- $model = self::findOne(['addons_name' => $params['addons_name'], 'name' => $params['name'], 'status' => StatusEnum::ENABLED]);
- if (empty($model)) {
- $model = new self();
- $model->loadDefaultValues();
- }
- if (!$model->load($params, '') || !$model->save()) {
- throw new RuntimeException($model->getErrorMessage());
- }
- return $model;
- } catch (\Exception $e) {
- self::$static_error = $e->getMessage();
- return false;
- }
- }
- }
|