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.

85 lines
2.1 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_category".
  7. *
  8. * @property int $id
  9. * @property string $name 类别名称
  10. * @property int $pid 父级id
  11. * @property int $goods_count 商品数量
  12. * @property int $sort_order 排序
  13. * @property int $icon_type 图标类型
  14. * @property string $icon 图标
  15. * @property int $is_show 是否显示,1为不显示
  16. * @property int $is_delete 是否删除,1为已删除
  17. * @property int $created_at 创建时间
  18. * @property int $updated_at 更新时间
  19. */
  20. class Category extends \yii\db\ActiveRecord
  21. {
  22. /**
  23. * {@inheritdoc}
  24. */
  25. public static function tableName()
  26. {
  27. return 'ats_category';
  28. }
  29. /**
  30. * {@inheritdoc}
  31. */
  32. public function rules()
  33. {
  34. return [
  35. [['pid', 'goods_count', 'sort_order', 'icon_type', 'is_show', 'is_delete'], 'integer'],
  36. [['name'], 'string', 'max' => 60],
  37. [['icon'], 'string', 'max' => 64],
  38. ];
  39. }
  40. /**
  41. * {@inheritdoc}
  42. */
  43. public function attributeLabels()
  44. {
  45. return [
  46. 'id' => 'id',
  47. 'name' => '类别名称',
  48. 'pid' => '父级id',
  49. 'goods_count' => '商品数量',
  50. 'sort_order' => '排序',
  51. 'icon_type' => '图标类型',
  52. 'icon' => '图标',
  53. 'is_show' => '是否显示,1为不显示',
  54. 'is_delete' => '是否删除,1为已删除',
  55. 'created_at' => '创建时间',
  56. 'updated_at' => '更新时间',
  57. ];
  58. }
  59. /**
  60. * @author linyao
  61. * @email 602604991@qq.com
  62. * @created Nov 8, 2019
  63. *
  64. * 行为存储创建时间和更新时间
  65. */
  66. public function behaviors()
  67. {
  68. return [
  69. [
  70. 'class' => TimestampBehavior::className(),
  71. 'createdAtAttribute' => 'created_at',
  72. 'updatedAtAttribute' => 'updated_at',
  73. 'value' => function() {
  74. return time();
  75. },
  76. ],
  77. ];
  78. }
  79. }