$this->query
                  
                  
                              ->select(['id', 'city_id', 'country_id', 'rating', 'about', 'name', 'surname', 'role', 'created_at'])
                  
                  
                              ->when(
                  
                  
                                  value: $city?->id,
                  
                  
                                  callback: fn(Builder $q) => $q->whereHas('tours', fn(Builder $q) => $city->type === City::TYPE_REGION ? $q->whereIn('city_id', $city->cities->pluck('id')) : $q->whereBelongsTo($city)),
                  
                  
                                  default: fn(Builder $q) => $q->whereHas('tours', fn(Builder $q) => $q->whereBelongsTo($country))->with('city'),
                  
                  
                              )
                  
                  
                              ->approved()
                  
                  
                              ->whereIn('role', [User::USER_GID, User::USER_COMPANY])
                  
                  
                              ->with(['counter', 'avatar'])
                  
                  
                              ->orderByDesc('rating')
                  
                  
                              ->orderByToursCount()
                  
                  
                              ->when(
                  
                  
                                  $this->usePagination,
                  
                  
                                  fn($q) => $q->paginate($this->per_page),
                  
                  
                                  fn($q) => $q->take($this->per_page)->get()
                  
                  
                              );
                  
                  
                
Лучше скинь скрином
Обсуждают сегодня