| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- <?php
- namespace addons\Pk\common\models;
- use Yii;
- /**
- * This is the model class for table "{{%addons_pk_setting}}".
- *
- * @property int $id
- * @property int $mall_id
- * @property string $key
- * @property string $value
- * @property int $status 状态[-1:删除;0:禁用;1启用]
- * @property int $created_at 创建时间
- * @property int $updated_at 修改时间
- */
- class PkSetting extends \common\models\base\BaseActiveRecord
- {
- const OPEN = 1;//开启
- const CLOSED = 0; //关闭
- const KEY_BASIC = "basic"; //基础配置;
- const KEY_RULES = "rules";
- const FEILD_NOT_ALLOW_APPLY_HOUR = 'not_allow_apply_hour';//-1不限制,禁止报名PK活动时间.
- const ALLOW_APPLY_HOUR = -1;//-1不限制,禁止报名PK活动时间.
- const FEILD_IS_TEAM_AUDIT = 'is_team_audit';//战队审核
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%addons_pk_setting}}';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['mall_id', 'key', 'value'], 'required'],
- [['mall_id', 'status', 'created_at', 'updated_at'], 'integer'],
- [['value'], 'string'],
- [['key'], 'string', 'max' => 255],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'mall_id' => 'Mall ID',
- 'key' => 'Key',
- 'value' => 'Value',
- 'status' => '状态[-1:删除;0:禁用;1启用]',
- 'created_at' => '创建时间',
- 'updated_at' => '修改时间',
- ];
- }
- /**
- * 单条数据
- * @param $mall_id
- * @return array|\yii\db\ActiveRecord|null
- */
- public function getOneItem($mall_id, $key)
- {
- return self::find()->where(['mall_id' => $mall_id, 'key' => $key])->one();
- }
- /**
- * 详情,json_encode过的
- * @param $mall_id
- * @return mixed
- */
- public function detail($mall_id, $key)
- {
- $one = $this->getOneItem($mall_id, $key);
- if(!empty($one) && !empty($one["value"])){
- $one = json_decode($one['value'], true);
- }
- return $one;
- }
- }
|