In Laravel 4.2 I have a model called Product with many-to-many relationshis to other models like Country or Category. I want to filter out products that are "incomplete", which means they have no connected countries or no connected categories. I can use whereDoesntHave()
method to filter out one relation. When I use it two times in one query it creates AND
condition, but I need OR
. I can't find orWhereDoesntHave()
method in API documentation. I can't pass multiple relations as arguments because it expects first argument to be a string.
我需要这样的东西:
$products = Product::whereDoesntHave('categories')->orWhereDoesntHave('countries')->get();
有没有办法在有多个OR
个条件的情况下达到whereDoesntHave()
分呢?