Querying entries where parent is null (root entries in a structure) does not work
Bug description
Hi, I am trying to query all entries that do not have a parent (root entries), however, this does not seem to work.
$entries = Entry::query()
->where('collection', 'destinations')
->where('parent', null)
->get();
$entries = Entry::query()
->where('collection', 'destinations')
->whereNull('parent')
->get();
Logs
No response
Versions
Statamic 3.3.17 Pro Laravel 8.83.18 PHP 8.1.4 doublethreedigital/duplicator 2.3.1 doublethreedigital/runway 2.4.0 spatie/statamic-health 1.0.0 statamic/collaboration 0.4.0
Installation
Existing Laravel app
Antlers Parser
runtime (new)
Additional details
No response
The parent data has been abstracted away from being stored on Entries and moved to the Tree structures.
So something like the following should work:
$pages = Collection::findByHandle('destinations')
->structure()
->in('default')
->flattenedPages()
->filter
->parent('parent-id')
Each element in $pages should be a Statamic\Structures\Page and you can call entry() on it to get the collection entry.
Can this issue be closed now? I see @ryanmitchell has provided a solution.