yaeykay
1 week ago

Laravel whereDoesntHave union whereHas

Posted 1 week ago by yaeykay

I'm trying to query my models that don't have relation and union it with the ones that have relations but I get an error with memory being exhausted.

Post::whereDoesntHave('comments')->union(Post::newQuery()->whereHas('comments')->getQuery())->paginate();

Anyone know a better way of using the union?

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