uksarkar
5 months ago

eloquent query doesn't working

Posted 5 months ago by uksarkar

I am writing a search pattern, my code is like this,

   $value = "something";
   $min = 10;
   $max= 100;
   $products = $product->where('name','like','%'.$value.'%')
                     ->orWhereHas('category',function($q) use($value){
                        $q->where('name','like','%'.$value.'%');
                     })
                     ->whereHas('prices',function($q) use($max){
                        $q->where('amounts','=<',$max);
                     })
                     ->whereHas('prices', function($q) use($min){
                        $q->where('amounts','>=', $min);
                     })
                     ->get();

but here the $min and $max value doesn't working. The result is coming without caring of min and max value.

Please sign in or create an account to participate in this conversation.