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.

71 lines
1.5 KiB

  1. <?php
  2. namespace common\models;
  3. use Yii;
  4. use yii\behaviors\TimestampBehavior;
  5. /**
  6. * This is the model class for table "category".
  7. *
  8. * @property int $id
  9. * @property string $cat_name
  10. * @property string $icon
  11. * @property int $icon_type
  12. * @property string $description
  13. * @property int $sort_order
  14. * @property int $created_at
  15. * @property int $updated_at
  16. */
  17. class Category extends \yii\db\ActiveRecord {
  18. const ICON_TYPE_BOOSTARAP = 1;
  19. const ICON_TYPE_AWESOME = 2;
  20. public static $iconType = [
  21. self::ICON_TYPE_BOOSTARAP => "boostrap",
  22. self::ICON_TYPE_AWESOME => "awesome"
  23. ];
  24. /**
  25. * {@inheritdoc}
  26. */
  27. public static function tableName() {
  28. return 'category';
  29. }
  30. /**
  31. * {@inheritdoc}
  32. */
  33. public function rules() {
  34. return [
  35. [['cat_name'], 'required'],
  36. [['icon_type', 'sort_order', 'created_at', 'updated_at'], 'integer'],
  37. [['description'], 'string'],
  38. [['cat_name', 'icon'], 'string', 'max' => 64],
  39. ];
  40. }
  41. /**
  42. * {@inheritdoc}
  43. */
  44. public function attributeLabels() {
  45. return [
  46. 'id' => 'ID',
  47. 'cat_name' => '类名',
  48. 'icon' => 'Icon',
  49. 'icon_type' => '图标类型',
  50. 'description' => '描述',
  51. 'sort_order' => 'Sort Order',
  52. 'created_at' => '添加日期',
  53. 'updated_at' => 'Updated At',
  54. ];
  55. }
  56. public function behaviors() {
  57. return [
  58. TimestampBehavior::className()
  59. ];
  60. }
  61. }