Loop through child pages

I’m trying to loop through all child pages in a blade view.

Right now i’m doing this in the view:

@if(App::childPages())
    @foreach(App::childPages() as $post)
        @php(setup_postdata($GLOBALS['post'] =& $post))

        <section>
            @include('partials.content-'.get_post_type())
        </section>
    @endforeach
@endif

and in the App controller:

public static function childPages()
{
    return get_pages([
        'sort_column' => 'menu_order',
        'sort_order' => 'ASC',
        'parent' => get_post()->ID,
        'post_type' => 'page',
    ]);
}

Which works, but is kind of ugly in my opinion.

I would like to keep the @php(setup_postdata($GLOBALS['post'] =& $post)) logic out of my view, does anybody know how to do that?

Thanks!

It’s not quite the same issue, but I came up with a few techniques regarding a similar problem that might be helpful: https://github.com/roots/sage/issues/1927#issuecomment-317138844