Sysconfig.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. namespace app\modules\admin\models;
  3. use Yii;
  4. /**
  5. * This is the model class for table "{{%sysconfig}}".
  6. *
  7. * @property int $id ID
  8. * @property string $name 配置标识符
  9. * @property string|null $value 配置
  10. * @property string $bak 备注
  11. * @property int $type 1:key-value 键值对
  12. * @property int $is_system 1:系统自带
  13. * @property int $list_order 排序
  14. * @property int $disabled 1:禁用
  15. */
  16. class Sysconfig extends \app\common\models\EActiveRecord
  17. {
  18. /**
  19. * {@inheritdoc}
  20. */
  21. public static function tableName()
  22. {
  23. return '{{%sysconfig}}';
  24. }
  25. /**
  26. * {@inheritdoc}
  27. */
  28. public function rules()
  29. {
  30. return [
  31. [['name','type','bak'], 'required'],
  32. [['value'], 'string'],
  33. [['type', 'is_system', 'list_order', 'disabled'], 'integer'],
  34. [['name', 'bak'], 'string', 'max' => 50],
  35. ];
  36. }
  37. /**
  38. * {@inheritdoc}
  39. */
  40. public function attributeLabels()
  41. {
  42. return [
  43. 'id' => Yii::t('attr','sysconfig.id'),
  44. 'name' => Yii::t('attr','sysconfig.name'),
  45. 'value' => Yii::t('attr','sysconfig.value'),
  46. 'bak' => Yii::t('attr','sysconfig.bak'),
  47. 'type' => Yii::t('attr','sysconfig.type'),
  48. 'is_system' => Yii::t('attr','sysconfig.is_system'),
  49. 'list_order' => Yii::t('attr','sysconfig.list_order'),
  50. 'disabled' => Yii::t('attr','sysconfig.disabled'),
  51. ];
  52. }
  53. //配置类型
  54. public static function typeOptions($k=null)
  55. {
  56. $options = array('1'=>'键值对','2'=>'普通选项组','3'=>'普通值');
  57. if(is_numeric($k))return $options[$k];
  58. return $options;
  59. }
  60. }