StoreBargainUserHelp.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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\activity\bargain;
  12. use app\model\user\User;
  13. use crmeb\basic\BaseModel;
  14. use crmeb\traits\ModelTrait;
  15. use think\Model;
  16. /**
  17. * 砍价帮砍Model
  18. * Class StoreBargainUserHelp
  19. * @package app\model\activity\bargain
  20. */
  21. class StoreBargainUserHelp extends BaseModel
  22. {
  23. /**
  24. * 数据表主键
  25. * @var string
  26. */
  27. protected $pk = 'id';
  28. /**
  29. * 模型名称
  30. * @var string
  31. */
  32. protected $name = 'store_bargain_user_help';
  33. use ModelTrait;
  34. /**
  35. * 关联用户
  36. * @return \crmeb\basic\BaseHasOne
  37. */
  38. public function getUser()
  39. {
  40. return $this->hasOne(User::class, 'uid', 'uid', false)->bind(['nickname', 'avatar', 'delete_time']);
  41. }
  42. /**
  43. * 用户搜索器
  44. * @param Model $query
  45. * @param $value
  46. * @param $data
  47. */
  48. public function searchUidAttr($query, $value, $data)
  49. {
  50. $query->where('uid', $value);
  51. }
  52. /**
  53. * 商品ID搜索器
  54. * @param Model $query
  55. * @param $value
  56. * @param $data
  57. */
  58. public function searchBargainIdAttr($query, $value, $data)
  59. {
  60. $query->where('bargain_id', $value);
  61. }
  62. /**
  63. * 砍价ID搜索器
  64. * @param $query
  65. * @param $value
  66. */
  67. public function searchBargainUserIdAttr($query, $value)
  68. {
  69. $query->where('bargain_user_id', $value);
  70. }
  71. /**
  72. * 砍价ID搜索器
  73. * @param $query
  74. * @param $value
  75. */
  76. public function searchTypeAttr($query, $value)
  77. {
  78. $query->where('type', $value);
  79. }
  80. }