UserAddress.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\model\user;
  12. use crmeb\basic\BaseModel;
  13. use crmeb\traits\ModelTrait;
  14. use think\model;
  15. /**
  16. * Class UserAddress
  17. * @package app\model\user
  18. */
  19. class UserAddress extends BaseModel
  20. {
  21. use ModelTrait;
  22. /**
  23. * 数据表主键
  24. * @var string
  25. */
  26. protected $pk = 'id';
  27. /**
  28. * 模型名称
  29. * @var string
  30. */
  31. protected $name = 'user_address';
  32. protected $insert = ['add_time'];
  33. protected $hidden = ['add_time', 'is_del'];
  34. /**
  35. * 更新之后事件
  36. * @param model $model
  37. */
  38. public static function onAfterUpdate(Model $model)
  39. {
  40. event('user.address.update');
  41. }
  42. protected function setAddTimeAttr()
  43. {
  44. return time();
  45. }
  46. /**
  47. * 用户uid
  48. * @param $query
  49. * @param $value
  50. */
  51. public function searchUidAttr($query, $value)
  52. {
  53. $query->where('uid', $value);
  54. }
  55. /**
  56. * 是否删除
  57. * @param Model $query
  58. * @param $value
  59. */
  60. public function searchIsDelAttr($query, $value)
  61. {
  62. $query->where('is_del', $value);
  63. }
  64. /**
  65. * 是否默认地址
  66. * @param Model $query
  67. * @param $value
  68. */
  69. public function searchIsDefaultAttr($query, $value)
  70. {
  71. $query->where('is_default', $value);
  72. }
  73. }