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.

88 lines
2.1 KiB

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