StoreConfig.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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\store;
  12. use app\model\user\User;
  13. use crmeb\basic\BaseModel;
  14. use crmeb\traits\ModelTrait;
  15. use think\Model;
  16. /**
  17. * 门店配置
  18. * Class StoreConfig
  19. * @package app\model\store
  20. */
  21. class StoreConfig extends BaseModel
  22. {
  23. use ModelTrait;
  24. /**
  25. * 数据表主键
  26. * @var string
  27. */
  28. protected $pk = 'id';
  29. /**
  30. * 模型名称
  31. * @var string
  32. */
  33. protected $name = 'store_config';
  34. /**
  35. * 商户搜索器
  36. * @param Model $query
  37. * @param $value
  38. */
  39. public function searchTypeAttr($query, $value)
  40. {
  41. if (is_array($value)) {
  42. if ($value) $query->whereIn('type', $value);
  43. } else {
  44. if ($value !== '') $query->where('type', $value);
  45. }
  46. }
  47. /**
  48. * 关联门店ID、供应商ID搜索器
  49. * @param Model $query
  50. * @param $value
  51. */
  52. public function searchRelationIdAttr($query, $value)
  53. {
  54. if (is_array($value)) {
  55. if ($value) $query->whereIn('relation_id', $value);
  56. } else {
  57. if ($value !== '') $query->where('relation_id', $value);
  58. }
  59. }
  60. /**
  61. * 供应商
  62. * @param Model $query
  63. * @param $value
  64. */
  65. public function searchSupplierIdAttr($query, $value)
  66. {
  67. if (is_array($value)) {
  68. if ($value) $query->whereIn('relation_id', $value)->where('type', 2);
  69. } else {
  70. if ($value !== '') $query->where('relation_id', $value)->where('type', 2);
  71. }
  72. }
  73. /**
  74. * 门店
  75. * @param Model $query
  76. * @param $value
  77. */
  78. public function searchStoreIdAttr($query, $value)
  79. {
  80. if (is_array($value)) {
  81. if ($value) $query->whereIn('relation_id', $value)->where('type', 1);
  82. } else {
  83. if ($value !== '') $query->where('relation_id', $value)->where('type', 1);
  84. }
  85. }
  86. /**
  87. * 关键字
  88. * @param $query
  89. * @param $value
  90. */
  91. public function searchKeyNameAttr($query, $value)
  92. {
  93. if ($value !== '') {
  94. $query->where('key_name', $value);
  95. }
  96. }
  97. }