Address.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <?php
  2. /**
  3. * 厦门云联储网络科技有限公司
  4. * https://www.baokuaiyun.com
  5. * Copyright (c) 2023 爆块云 All rights reserved.
  6. */
  7. namespace app\models;
  8. use app\models\common\admin\log\CommonActionLog;
  9. use Yii;
  10. use yii\helpers\Html;
  11. /**
  12. * This is the model class for table "{{%address}}".
  13. *
  14. * @property integer $id
  15. * @property integer $store_id
  16. * @property integer $user_id
  17. * @property string $name
  18. * @property string $mobile
  19. * @property integer $province_id
  20. * @property string $province
  21. * @property integer $city_id
  22. * @property string $city
  23. * @property integer $district_id
  24. * @property string $district
  25. * @property string $detail
  26. * @property integer $is_default
  27. * @property integer $addtime
  28. * @property integer $is_delete
  29. * @property string $latitude
  30. * @property string $longitude
  31. */
  32. class Address extends \yii\db\ActiveRecord
  33. {
  34. /**
  35. * 默认状态:默认地址
  36. */
  37. const DEFAULT_STATUS_TRUE = 1;
  38. /**
  39. * 默认状态:非默认地址
  40. */
  41. const DEFAULT_STATUS_FALSE = 0;
  42. /**
  43. * 删除状态:已删除
  44. */
  45. const DELETE_STATUS_TRUE = 1;
  46. /**
  47. * 删除状态:未删除
  48. */
  49. const DELETE_STATUS_FALSE = 0;
  50. /**
  51. * @inheritdoc
  52. */
  53. public static function tableName()
  54. {
  55. return '{{%address}}';
  56. }
  57. /**
  58. * @inheritdoc
  59. */
  60. public function rules()
  61. {
  62. return [
  63. [['store_id', 'user_id', 'name', 'mobile', 'province', 'city', 'district', 'detail'], 'required'],
  64. [['store_id', 'user_id', 'province_id', 'city_id', 'district_id', 'town_id', 'village_id', 'is_default', 'addtime', 'is_delete'], 'integer'],
  65. [['name', 'mobile', 'province', 'city', 'district','town', 'village', 'latitude', 'longitude'], 'string', 'max' => 255],
  66. [['detail'], 'string', 'max' => 1000],
  67. ];
  68. }
  69. /**
  70. * @inheritdoc
  71. */
  72. public function attributeLabels()
  73. {
  74. return [
  75. 'id' => 'ID',
  76. 'store_id' => 'Store ID',
  77. 'user_id' => 'User ID',
  78. 'name' => '姓名',
  79. 'mobile' => '手机号',
  80. 'province_id' => 'Province ID',
  81. 'province' => '省份名称',
  82. 'city_id' => 'City ID',
  83. 'city' => '城市名称',
  84. 'district_id' => 'District ID',
  85. 'district' => '县区名称',
  86. 'town_id' => 'town ID',
  87. 'town' => '镇名称',
  88. 'village_id' => 'Village ID',
  89. 'village' => '村名称',
  90. 'detail' => '详细地址',
  91. 'is_default' => '是否是默认地址:0=否,1=是',
  92. 'addtime' => 'Addtime',
  93. 'is_delete' => 'Is Delete',
  94. 'latitude' => '地址纬度',
  95. 'longitude' => '地址经度',
  96. ];
  97. }
  98. public function beforeSave($insert)
  99. {
  100. $this->name = Html::encode($this->name);
  101. $this->mobile = Html::encode($this->mobile);
  102. $this->detail = Html::encode($this->detail);
  103. return parent::beforeSave($insert);
  104. }
  105. }