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.

91 lines
2.2 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_address".
  7. *
  8. * @property int $id
  9. * @property int $user_id 用户id
  10. * @property string $consignee 收件人
  11. * @property string $phone 电话
  12. * @property string $province 省份
  13. * @property string $city 城市
  14. * @property string $area 区域
  15. * @property string $address 详细地址
  16. * @property int $status 状态,0-默认值 1-默认地址
  17. * @property int $created_at 创建时间
  18. * @property int $updated_at 更新时间
  19. */
  20. class Address extends \yii\db\ActiveRecord
  21. {
  22. const STATUS_DEFAULT = 1;
  23. const STATUS_NOT_DEFAULT = 0;
  24. /**
  25. * {@inheritdoc}
  26. */
  27. public static function tableName()
  28. {
  29. return 'ats_address';
  30. }
  31. /**
  32. * {@inheritdoc}
  33. */
  34. public function rules()
  35. {
  36. return [
  37. [['user_id', 'consignee', 'phone', 'address'], 'required'],
  38. [['user_id', 'status'], 'integer'],
  39. [['address'], 'string'],
  40. [['consignee', 'phone'], 'string', 'max' => 20],
  41. [['province', 'city', 'area'], 'string', 'max' => 10],
  42. ];
  43. }
  44. /**
  45. * {@inheritdoc}
  46. */
  47. public function attributeLabels()
  48. {
  49. return [
  50. 'id' => 'id',
  51. 'user_id' => '用户id',
  52. 'consignee' => '收件人',
  53. 'phone' => '电话',
  54. 'province' => '省份',
  55. 'city' => '城市',
  56. 'area' => '区域',
  57. 'address' => '详细地址',
  58. 'status' => '状态,0-默认值 1-默认地址',
  59. 'created_at' => '创建时间',
  60. 'updated_at' => '更新时间',
  61. ];
  62. }
  63. /**
  64. * @author linyao
  65. * @email 602604991@qq.com
  66. * @created Nov 8, 2019
  67. *
  68. * 行为存储创建时间和更新时间
  69. */
  70. public function behaviors()
  71. {
  72. return [
  73. [
  74. 'class' => TimestampBehavior::className(),
  75. 'createdAtAttribute' => 'created_at',
  76. 'updatedAtAttribute' => 'updated_at',
  77. 'value' => function () {
  78. return time();
  79. },
  80. ],
  81. ];
  82. }
  83. }