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.

73 lines
1.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_collection".
  7. *
  8. * @property int $id
  9. * @property int $user_id 用户id
  10. * @property int $goods_id 商品id
  11. * @property int $updated_at 更新时间
  12. * @property int $created_at 创建时间
  13. */
  14. class Collection extends \yii\db\ActiveRecord
  15. {
  16. /**
  17. * {@inheritdoc}
  18. */
  19. public static function tableName()
  20. {
  21. return 'ats_collection';
  22. }
  23. /**
  24. * {@inheritdoc}
  25. */
  26. public function rules()
  27. {
  28. return [
  29. [['user_id', 'goods_id'], 'required'],
  30. [['user_id', 'goods_id'], 'integer'],
  31. ];
  32. }
  33. /**
  34. * {@inheritdoc}
  35. */
  36. public function attributeLabels()
  37. {
  38. return [
  39. 'id' => 'id',
  40. 'user_id' => '用户id',
  41. 'goods_id' => '商品id',
  42. 'updated_at' => '更新时间',
  43. 'created_at' => '创建时间',
  44. ];
  45. }
  46. /**
  47. * @author linyao
  48. * @email 602604991@qq.com
  49. * @created Nov 8, 2019
  50. *
  51. * 行为存储创建时间和更新时间
  52. */
  53. public function behaviors()
  54. {
  55. return [
  56. [
  57. 'class' => TimestampBehavior::className(),
  58. 'createdAtAttribute' => 'created_at',
  59. 'updatedAtAttribute' => 'updated_at',
  60. 'value' => function() {
  61. return time();
  62. },
  63. ],
  64. ];
  65. }
  66. }