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.

94 lines
2.5 KiB

  1. <?php
  2. namespace common\models\ars;
  3. use Yii;
  4. use yii\behaviors\TimestampBehavior;
  5. /**
  6. * This is the model class for table "ats_shop_category".
  7. *
  8. * @property int $id
  9. * @property string $name 类别名称
  10. * @property int $pid 父级id
  11. * @property int $goods_count 商品数量
  12. * @property string $keywords 关键字
  13. * @property string $desc 描述
  14. * @property int $sort_order 排序
  15. * @property int $icon_type 图标类型
  16. * @property string $icon 图标
  17. * @property string $filter_attr 筛选属性
  18. * @property int $is_show 是否显示,1为不显示
  19. * @property int $is_delete 是否删除,1为已删除
  20. * @property int $created_at 创建时间
  21. * @property int $updated_at 更新时间
  22. */
  23. class ShopCategory extends \yii\db\ActiveRecord
  24. {
  25. /**
  26. * {@inheritdoc}
  27. */
  28. public static function tableName()
  29. {
  30. return 'ats_shop_category';
  31. }
  32. /**
  33. * {@inheritdoc}
  34. */
  35. public function rules()
  36. {
  37. return [
  38. [['pid', 'goods_count', 'sort_order', 'icon_type', 'is_show', 'is_delete'], 'integer'],
  39. [['filter_attr'], 'string'],
  40. [['name'], 'string', 'max' => 60],
  41. [['keywords'], 'string', 'max' => 100],
  42. [['desc'], 'string', 'max' => 255],
  43. [['icon'], 'string', 'max' => 64],
  44. ];
  45. }
  46. /**
  47. * {@inheritdoc}
  48. */
  49. public function attributeLabels()
  50. {
  51. return [
  52. 'id' => 'id',
  53. 'name' => '类别名称',
  54. 'pid' => '父级id',
  55. 'goods_count' => '商品数量',
  56. 'keywords' => '关键字',
  57. 'desc' => '描述',
  58. 'sort_order' => '排序',
  59. 'icon_type' => '图标类型',
  60. 'icon' => '图标',
  61. 'filter_attr' => '筛选属性',
  62. 'is_show' => '是否显示,1为不显示',
  63. 'is_delete' => '是否删除,1为已删除',
  64. 'created_at' => '创建时间',
  65. 'updated_at' => '更新时间',
  66. ];
  67. }
  68. /**
  69. * @author linyao
  70. * @email 602604991@qq.com
  71. * @created Nov 8, 2019
  72. *
  73. * 行为存储创建时间和更新时间
  74. */
  75. public function behaviors()
  76. {
  77. return [
  78. [
  79. 'class' => TimestampBehavior::className(),
  80. 'createdAtAttribute' => 'created_at',
  81. 'updatedAtAttribute' => 'updated_at',
  82. 'value' => function() {
  83. return time();
  84. },
  85. ],
  86. ];
  87. }
  88. }