Temporary Disable Appends in the Related Model:
Hey, what do you think about below code, does it create any performance issue? or should I remove each()?
$users = User::with('blogs')->get();
$users->each(function ($user) {
if ($user->relationLoaded('chat_room')) {
$user->blogs->setAppends([]); // Remove all appended attributes
}
});
@amitsolanki24_ I don't see any radical performance issue.
Just a nitpick!
User::with('blogs')->chunk(100, function ($users) {
$users->each(function ($user) {
if ($user->relationLoaded('blogs') && $user->relationLoaded('chat_room')) {
$user->blogs->setAppends([]);
}
});
});
@tisuchi yeah, it's a minor issue but i want know how can I use eloquent more faster or something else to fetch blogs without appends.
Please or to participate in this conversation.