RelationUserFilter.php 771 B

1234567891011121314151617181920212223242526272829
  1. <?php
  2. namespace App\Filters\Traits;
  3. use Illuminate\Database\Eloquent\Builder;
  4. trait RelationUserFilter
  5. {
  6. protected function mobile($val)
  7. {
  8. $this->builder->whereHas('users', function (Builder $query) use ($val) {
  9. $query->where('mobile', 'like', "%{$val}%");
  10. });
  11. }
  12. protected function nickname($val)
  13. {
  14. $this->builder->whereHas('users', function (Builder $query) use ($val) {
  15. $query->where('nickname', 'like', "%{$val}%");
  16. });
  17. }
  18. protected function mobileNickname($val){
  19. $this->builder->whereHas('users', function (Builder $query) use ($val) {
  20. $query->where('mobile', 'like', "%{$val}%")
  21. ->Orwhere('nickname', 'like', "%{$val}%");
  22. });
  23. }
  24. }