GoodsBook.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /**
  3. * 厦门云联储网络科技有限公司
  4. * https://www.baokuaiyun.com
  5. * Copyright (c) 2023 爆块云 All rights reserved.
  6. */
  7. namespace app\models;
  8. /**
  9. * This is the model class for table "{{%goods_book}}".
  10. *
  11. * @property integer $id
  12. * @property integer $goods_id
  13. * @property string $date_book
  14. * @property string $service_book
  15. * @property integer $created_at
  16. */
  17. class GoodsBook extends \yii\db\ActiveRecord
  18. {
  19. /**
  20. * @inheritdoc
  21. */
  22. public static function tableName()
  23. {
  24. return '{{%goods_book}}';
  25. }
  26. /**
  27. * @inheritdoc
  28. */
  29. public function rules()
  30. {
  31. return [
  32. [['goods_id'], 'required'],
  33. [['created_at', 'goods_id'], 'integer'],
  34. [['date_book', 'service_book'], 'string'],
  35. ];
  36. }
  37. /**
  38. * @inheritdoc
  39. */
  40. public function attributeLabels()
  41. {
  42. return [
  43. 'id' => 'ID',
  44. 'goods_id' => '商品id',
  45. 'date_book' => '酒店预约商品',
  46. 'service_book' => '服务预约商品',
  47. 'created_at' => 'Addtime',
  48. ];
  49. }
  50. public function beforeSave($insert)
  51. {
  52. if (parent::beforeSave($insert)) {
  53. if ($this->isNewRecord) {
  54. $this->created_at = time();
  55. }
  56. return true;
  57. }
  58. return false;
  59. }
  60. }