Pond.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. namespace app\models;
  3. use yii\behaviors\TimestampBehavior;
  4. use yii\db\ActiveRecord;
  5. /**
  6. * This is the model class for table "{{%pond}}".
  7. *
  8. * @property integer $id
  9. * @property integer $store_id
  10. * @property integer $type
  11. * @property string $name
  12. * @property string $image_url
  13. * @property integer $winning_rate
  14. * @property integer $stock
  15. * @property integer $gift_id
  16. * @property integer $create_time
  17. * @property integer $update_time
  18. * @property integer $user_id
  19. */
  20. class Pond extends \yii\db\ActiveRecord
  21. {
  22. /**
  23. * @inheritdoc
  24. */
  25. public static function tableName()
  26. {
  27. return '{{%pond}}';
  28. }
  29. /**
  30. * @inheritdoc
  31. */
  32. public function rules()
  33. {
  34. return [
  35. [['store_id', 'name'], 'required'],
  36. [['store_id', 'type', 'stock', 'gift_id', 'create_time', 'update_time', 'user_id', 'winning_rate'], 'integer'],
  37. [['image_url'], 'string', 'max' => 255],
  38. ];
  39. }
  40. public function behaviors()
  41. {
  42. return [
  43. [
  44. 'class' => TimestampBehavior::class,
  45. 'attributes' => [
  46. ActiveRecord::EVENT_BEFORE_INSERT => ['update_time', 'create_time'],
  47. ActiveRecord::EVENT_BEFORE_UPDATE => 'update_time'
  48. ]
  49. ]
  50. ];
  51. }
  52. /**
  53. * @inheritdoc
  54. */
  55. public function attributeLabels()
  56. {
  57. return [
  58. 'id' => 'ID',
  59. 'store_id' => 'Store ID',
  60. 'type' => '1.谢谢惠顾 2.商品',
  61. 'name' => '奖品名称',
  62. 'image_url' => '图片',
  63. 'winning_rate' => '中奖率',
  64. 'stock' => '库存',
  65. 'gift_id' => '赠品',
  66. 'create_time' => 'Create Time',
  67. 'update_time' => 'Update Time',
  68. 'user_id' => '指定中奖用户id',
  69. ];
  70. }
  71. public function getGift()
  72. {
  73. return $this->hasOne(Goods::className(), ['id' => 'gift_id']);
  74. }
  75. }