@if($children)
    @foreach($children as $child)
        <option value="{{ $child->id }}" @if(isset($selectedPageId)) @if($child->id == $selectedPageId) selected @endif @endif>
            {{ $prefix }} {{ $child->title }}
        </option>
        @if($child->children->count() > 0)
            @if(isset($selectedPageId))
                @include('partials.sub-pages', ['children' => $child->children, 'prefix' => $prefix . '--', 'selectedPageId' => $selectedPageId])
            @else
                @include('partials.sub-pages', ['children' => $child->children, 'prefix' => $prefix . '--'])
            @endif
        @endif
    @endforeach
@endif