I think you are right. Append data to $groupCategories is the right way. As per documentation, The fourth param is what will be displayed if the $groupCategories is empty. You can either pass a view template, which will be shown only once, or any text prepended with raw| will be displayed as is.
General format:
@each('viewfile-to-render', $data, 'variablename','optional-empty-viewfile')
The first argument is the template to render. This will usually be a partial, like your nameofyourblade.blade.php.
The second one is the iterable dataset, in your case $groupCategories.
The Third is the variable name the elements will use when being iterated upon. For example, in foreach ($data as $element), this argument would be element (without the $).
The fourth argument is an optional one – it’s the name of the template file which should be rendered when the second argument ($data) is empty, i.e. has nothing to iterate over. If we apply all this to our case, we can replace this entire block:
@if (count($groupCategories) > 0)
<ul>
@foreach ($groupCategories as $parent)
@include('partials.nav.categories', $parent)
@endforeach
</ul>
@else
@include('partials.group-none')
@endif
with
@each('partials.nav.categories', $groupCategories, 'parent', 'partials.group-none')
@each('partials.nav.categories', [$groupCategories,$moreVariable], 'parent')@foreachand@includedirectives instead? They'll give all you the flexibility you need while still maintaining readability.