'photographers' => User::where([
                  
                  
                                  ['status','=', 'verified'],
                  
                  
                                  ['role','=', 'photographer'],
                  
                  
                                  ['email_verified_at','!=', null]
                  
                  
                                  ])
                  
                  
                                  ->when($this->locale, function ($query) {
                  
                  
                                      return $query->where('locale', 'like','%'.$this->locale.'%');
                  
                  
                                  })
                  
                  
                                  ->when([$this->min,$this->max], function($query) {
                  
                  
                                      return $query->whereHas('photographer_posts', function($query) {
                  
                  
                                          return $query->whereBetween('hourly_cost', [$this->min,$this->max]);
                  
                  
                                      });
                  
                  
                                  })->when($this->category, function($query) {
                  
                  
                                      return $query->whereHas('photographer_posts', function($query){
                  
                  
                                          return $query->where('photographer_posts.category_id', $this->category);
                  
                  
                                      });
                  
                  
                                  })->get(),
                  
                  
                  
                  
                  
                              'categories' => PhotographerCategory::all()
                  
                  
                          ]);
                  
                  
                
Адаптировать под что? https://pastebin.com
Обсуждают сегодня