You don't need to use the pages methods. They are pure helper functions.
Filter the result to only contain published
pages.
foreach( $pages->published() as $item ) {
echo $item->title() . ' ' . $item->getStatus() . '<br>';
}
Filter the result to only contain unpublished
pages.
foreach( $pages->unpublished() as $item ) {
echo $item->title() . ' ' . $item->getStatus() . '<br>';
}
Filter the result to only contain private
pages.
foreach( $pages->private() as $item ) {
echo $item->title() . ' ' . $item->getStatus() . '<br>';
}
Filter the result to contain private
and published
pages.
foreach( $pages->privatePublished() as $item ) {
echo $item->title() . ' ' . $item->getStatus() . '<br>';
}
$collection = ( ! site()->user() ) ? $pages->published() : $pages->privatePublished();
foreach( $collection as $item ) {
echo $item->title() . ' ' . $item->getStatus() . '<br>';
}