5

Facing a strange issue in laravel. Everything works fine normally database working fine for normal read/write operations and for regular eloquent queries. But when I use

$query->whereHas('some_related_model',function($q){
         $q->whereIn('column_on_related_model_table',[array_values]);

})

It gives connect refused error as show in the title I am using laravel 6.x, mySql 8.0 and php v7.4

I have written a generalized code above. It happens for every whereHas specially inverse relationships like BelongsTo

wali razzaq
  • 83
  • 1
  • 7

1 Answers1

0

I recently encountered the same issue. Turns out it was because of a global scope, which was included on the relationship model. The global scope added a count of children to the relationship. Without the global scope, it worked fine. I haven't really paid more attention to it, as to why it failed with global scope, because the count isn't needed for the initial query.

Thomas Roovers
  • 116
  • 2
  • 9