beyondcode/laravel-query-detector

False Positive N+1 Queries

helderneves91 opened this issue · 0 comments

Hello, I was testing this package and got right way a false positive, at least, I think.

I have a model Template, and this template has a type, which has a Type model.

I have configured edger loading on Template model to always load Type relations.

Template model:
public $with = ['type'];
public function type() { return $this->hasOne('App\Models\SGC\Contracts\Templates\Types\Type', 'id', 'type_id'); }

When I do, for eg: Contract::with('template')->find(1), I got the error warning N+1 queries and that I should add with('type') to eager load the relation.

Am I doing something wrong?
Thanks.