Checking if child has no tag (callback for groupby)?

Hey again,

I need to check if one of the children of a given page doesn’t have a tag, so
if one of the children doesn’t have at least one tag, do this OTHERWISE do that.

isNotEmpty() doesn’t work on this array of children …

// Edit:
The error I get is Invalid grouping value for key: and then the first page that doesn’t have a tag

What do you want to do with group by? To check if one of the children has an empty tags field you can use filterBy():

<?php
if($page->children()->filterBy('tags', '==', '')->count() > 0) {
  echo "At least one of the children has an empty tags field";
} else {
  echo "None of the children has an empty tags field";
}
?>
1 Like