slipperydippery
3 months ago

Memory exhausted when $channel->comments but not for Comment::where('channel_id), $channel->id)->get()

Posted 3 months ago by slipperydippery

I have a query where I want to get a subset of all comments in a discussion channel.

$channel->comments
	->where('type', 3);

But I am running into a memory exhausted error. When I swap out this query for:

Comment::where('channel_id', $channel->id)
	->where('type', 3)
	->get();

This works without exhausting the memory. What is the reason for this? And where can I read up more about the inner workings of eloquent?

Thanks in advance!

Please sign in or create an account to participate in this conversation.