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.

86 lines
2.1 KiB

  1. <?php
  2. namespace backend\modules\shop\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. * @property string $sku_value 商品sku
  19. */
  20. class Cart extends \yii\db\ActiveRecord
  21. {
  22. /**
  23. * {@inheritdoc}
  24. */
  25. public static function tableName()
  26. {
  27. return 'ats_cart';
  28. }
  29. /**
  30. * {@inheritdoc}
  31. */
  32. public function rules()
  33. {
  34. return [
  35. [['user_id', 'goods_id', 'goods_name', 'sku_id'], 'required'],
  36. [['user_id', 'goods_id', 'goods_img', 'goods_price', 'sku_id', 'goods_count'], 'integer'],
  37. [['goods_name', 'sku_value'], 'string', 'max' => 120],
  38. ];
  39. }
  40. /**
  41. * {@inheritdoc}
  42. */
  43. public function attributeLabels()
  44. {
  45. return [
  46. 'id' => 'id',
  47. 'user_id' => '用户id',
  48. 'goods_id' => '商品id',
  49. 'goods_name' => '商品名称',
  50. 'goods_img' => '商品图片',
  51. 'goods_price' => '商品售价',
  52. 'sku_id' => '商品sku的id',
  53. 'goods_count' => '商品数量',
  54. 'created_at' => '创建时间',
  55. 'updated_at' => '更新时间',
  56. 'sku_value' => '商品sku',
  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. }