You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

125 lines
2.8 KiB

  1. <?php
  2. namespace common\models;
  3. use iron\wegets\Upload;
  4. use Yii;
  5. use yii\behaviors\TimestampBehavior;
  6. /**
  7. * This is the model class for table "category".
  8. *
  9. * @property int $id
  10. * @property string $cat_name
  11. * @property string $icon
  12. * @property int $icon_type
  13. * @property string $description
  14. * @property int $sort_order
  15. * @property int $created_at
  16. * @property int $updated_at
  17. */
  18. class Category extends \yii\db\ActiveRecord
  19. {
  20. const ICON_TYPE_BOOSTARAP = 1;
  21. const ICON_TYPE_AWESOME = 2;
  22. public static $iconType = [
  23. self::ICON_TYPE_BOOSTARAP => "boostrap",
  24. self::ICON_TYPE_AWESOME => "awesome"
  25. ];
  26. /**
  27. * {@inheritdoc}
  28. */
  29. public static function tableName()
  30. {
  31. return 'category';
  32. }
  33. /**
  34. * {@inheritdoc}
  35. */
  36. public function rules()
  37. {
  38. return [
  39. [['icon_type', 'cat_name', 'created_at'], 'required'],
  40. [['icon_type', 'sort_order', 'created_at', 'updated_at'], 'integer'],
  41. [['description'], 'string'],
  42. [['cat_name', 'icon'], 'string', 'max' => 64],
  43. ];
  44. }
  45. /**
  46. * {@inheritdoc}
  47. */
  48. public function attributeLabels()
  49. {
  50. return [
  51. 'id' => 'ID',
  52. 'cat_name' => '类名',
  53. 'icon' => 'Icon',
  54. 'icon_type' => '图标类型',
  55. 'description' => '描述',
  56. 'sort_order' => 'Sort Order',
  57. 'created_at' => '添加日期',
  58. 'updated_at' => 'Updated At',
  59. ];
  60. }
  61. /**
  62. * @return array
  63. * 列格式
  64. */
  65. public static function columns()
  66. {
  67. return [
  68. [
  69. 'class' => 'blobt\grid\CheckboxColumn',
  70. 'width' => '2%',
  71. 'align' => 'center'
  72. ],
  73. [
  74. 'attribute' => 'id',
  75. 'width' => '10%',
  76. 'align' => 'center'
  77. ],
  78. [
  79. 'attribute' => 'created_at',
  80. 'width' => '10%',
  81. 'format' => 'date'
  82. ],
  83. [
  84. 'attribute' => 'cat_name',
  85. 'width' => '10%',
  86. ],
  87. [
  88. 'attribute' => 'icon',
  89. 'width' => '10%',
  90. ],
  91. [
  92. 'attribute' => 'icon_type',
  93. 'width' => '10%',
  94. 'showConstText' => true
  95. ],
  96. [
  97. 'attribute' => 'description',
  98. 'enableSorting' => false,
  99. 'format' => 'ntext',
  100. 'width' => '20%',
  101. ],
  102. [
  103. 'class' => 'iron\grid\ActionColumn',
  104. 'align' => 'center',
  105. ],
  106. ];
  107. }
  108. public function behaviors()
  109. {
  110. return [
  111. TimestampBehavior::className()
  112. ];
  113. }
  114. }