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.

82 lines
1.9 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_cart".
  7. *
  8. * @property int $id
  9. * @property int $user_id 用户id
  10. * @property int $goods_id 商品id
  11. * @property string $goods_name 商品名称
  12. * @property int $goods_img 商品图片
  13. * @property int $goods_price 商品售价
  14. * @property int $sku_id 商品sku的id
  15. * @property int $goods_count 商品数量
  16. * @property int $created_at 创建时间
  17. * @property int $updated_at 更新时间
  18. */
  19. class Cart extends \yii\db\ActiveRecord
  20. {
  21. /**
  22. * {@inheritdoc}
  23. */
  24. public static function tableName()
  25. {
  26. return 'ats_cart';
  27. }
  28. /**
  29. * {@inheritdoc}
  30. */
  31. public function rules()
  32. {
  33. return [
  34. [['user_id', 'goods_id', 'goods_img', 'goods_price', 'sku_id', 'goods_count'], 'integer'],
  35. [['goods_name'], 'string', 'max' => 120],
  36. ];
  37. }
  38. /**
  39. * {@inheritdoc}
  40. */
  41. public function attributeLabels()
  42. {
  43. return [
  44. 'id' => 'id',
  45. 'user_id' => '用户id',
  46. 'goods_id' => '商品id',
  47. 'goods_name' => '商品名称',
  48. 'goods_img' => '商品图片',
  49. 'goods_price' => '商品售价',
  50. 'sku_id' => '商品sku的id',
  51. 'goods_count' => '商品数量',
  52. 'created_at' => '创建时间',
  53. 'updated_at' => '更新时间',
  54. ];
  55. }
  56. /**
  57. * @author linyao
  58. * @email 602604991@qq.com
  59. * @created Nov 8, 2019
  60. *
  61. * 行为存储创建时间和更新时间
  62. */
  63. public function behaviors()
  64. {
  65. return [
  66. [
  67. 'class' => TimestampBehavior::className(),
  68. 'createdAtAttribute' => 'created_at',
  69. 'updatedAtAttribute' => 'updated_at',
  70. 'value' => function() {
  71. return time();
  72. },
  73. ],
  74. ];
  75. }
  76. }