Level 122
I stopped trying to use with in my models and have not looked back
Hi,
How can i overwrite the $with in the model without removing it?
I found setEagerLoads and it is working great. However, when I tried it to other relationship, it will not work.
select('id', 'name', 'slug', 'professional_category_id')
->withCount(['reviews', 'connections', 'ratings'])
->NoEagerLoads() <- this is working, the scope is the same with the address.php
->IncludeMediaFile()
->with([
'address' => function($query) {
$query->select('city_id', 'city_name', 'state_name', 'addressable_id', 'addressable_type')
->noEagerLoads();
}
])
Address.php
protected $with = [
'city',
'state',
'country',
];
public function scopeNoEagerLoads($query) {
return $query->setEagerLoads([]);
}
I found the problem, there's a getter that query the other tables. just need to refactor it and the issue is now fixed.
@Snapey It becomes a burden when your applicant gets bigger. Too many unnecessary calls. -_-
Please or to participate in this conversation.