StationSearch.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. namespace catchAdmin\stations\model;
  3. use catchAdmin\permissions\model\Department;
  4. trait StationSearch
  5. {
  6. /**
  7. * 基站名称
  8. */
  9. public function searchStationNameAttr($query, $value, $data)
  10. {
  11. return $query->where('station_name', 'like', '%'. $value . '%');
  12. }
  13. /**
  14. * 基站类型
  15. */
  16. public function searchStationTypeAttr($query, $value, $data)
  17. {
  18. return $query->where('station_type',$value);
  19. }
  20. /**
  21. * 基站mac
  22. */
  23. public function searchStationMacAttr($query, $value, $data)
  24. {
  25. return $query->where('station_mac',$value);
  26. }
  27. /**
  28. * 基站简码
  29. */
  30. public function searchStationCodeAttr($query, $value, $data)
  31. {
  32. return $query->where('station_code',$value);
  33. }
  34. /**
  35. * 省
  36. */
  37. public function searchProvinceIdAttr($query, $value, $data)
  38. {
  39. return $query->where('province_id',$value);
  40. }
  41. /**
  42. * 市
  43. */
  44. public function searchCityIdAttr($query, $value, $data)
  45. {
  46. return $query->where('city_id',$value);
  47. }
  48. /**
  49. * 县
  50. */
  51. public function searchDistrictIdAttr($query, $value, $data)
  52. {
  53. return $query->where('district_id',$value);
  54. }
  55. /**
  56. * 学校id
  57. */
  58. public function searchSchoolIdAttr($query, $value, $data)
  59. {
  60. return $query->where('school_id',$value);
  61. }
  62. /**
  63. * 年级id
  64. */
  65. public function searchGradeIdAttr($query, $value, $data)
  66. {
  67. return $query->where('grade_id',$value);
  68. }
  69. /**
  70. * 建筑id
  71. */
  72. public function searchBuildingIdAttr($query, $value, $data)
  73. {
  74. return $query->where('building_id',$value);
  75. }
  76. /**
  77. * 楼层id
  78. */
  79. public function searchFloorIdAttr($query, $value, $data)
  80. {
  81. return $query->where('floor_id',$value);
  82. }
  83. /**
  84. * 城市:省/市/区/
  85. */
  86. public function searchCitysAttr($query, $value, $data)
  87. {
  88. if (empty($value)) {
  89. return $query;
  90. }
  91. return $query->where('province_id|city_id|district_id', 'in', $value);
  92. }
  93. }