Laravel whereDoesntHave() - multiple OR conditions

Since Laravel 5.5 there is an orWhereDoesntHave function.

You may use it like this

Product::whereDoesntHave('categories', function($q){ //... })
       ->orWhereDoesntHave('countries', function($q){//...})
       ->get();

From you example it seems that you are not using a where clause, so you may just use

Product::doesntHave('categories')
       ->orDoesntHave('countries')
       ->get();

You can use doesntHave and specify the boolean operator:

$products = Product::doesntHave('categories')->doesntHave('countries', 'or')->get();

Actually you only need whereDoesntHave if you want to pass in a closure to filter the related models before checking if any of them exist. In case you want to do that you can pass the closure as third argument:

$products = Product::doesntHave('categories', 'or', function($q){
    $q->where('active', false);
})->doesntHave('countries', 'or')->get();

Use

Product::whereDoesntHave('categories')->doesntHave('countries', 'or')->get();

Laravel Source Code:

whereDoesntHave https://github.com/illuminate/database/blob/master/Eloquent/Builder.php#L654 calls https://github.com/illuminate/database/blob/master/Eloquent/Builder.php#L628 internally.