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.

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