Closed milosb793 closed 1 year ago
@milosb793 The relationships is not inheriting any cache settings from the main query.
User::noCache()
+ ->with(['team' => fn ($q) => $q->noCache()])
- ->with(['team'])
->where('email', 'user@example.com')
->first();
Just a heads-up if anyone else is having such issues, it's dontCache()
instead of noCache()
:
User::noCache()
->with(['team' => fn ($q) => $q->dontCache()])
->with(['team'])
->where('email', 'user@example.com')
->first();
When using
Model::dontCache()
method, seems like it doesn't apply to relations. Model don't cache, but relations does. Here's an example:In this case, a user will not be cached, but a team will.
Is there any workaround for this?