Unable to loop through sub-pages

I have a page X that has multiple sub-pages. I want to loop through those subpages and display content from each sub-page on page X. But, I’m unable to and I’m not getting any errors. Here is my PHP code –

<?php $pastdeals = $page->deals()->toPages() ?>
<?php foreach ($pastdeals as $pastdeal): ?>
    <div>
        <img src="<?= $pastdeal->image()->toFile()->url() ?>">
        <span>
            <p>Location: <?= $pastdeal->location() ?></p>
            <p>Built-Up Area: <?= $pastdeal->builtuparea() ?></p>
        </span>
    </div>
<?php endforeach ?>

Here is the blueprint for page X –

sections:	
	content:
		type: fields
		fields:
			description:
				label: Past Deals Description
				type: textarea
	deals:
		type: pages

Here is the blueprint for the sub-pages –

sections:	
	content:
		type: fields
		fields:
			image:
				label: Picture
				type: files
				max: 1
			location:
				label: Location
				type: text
			builtuparea:
				label: Built-Up Area
				type: text

deal is a section, not a field. So you simply fetch the subpages:

<?php $pastdeals = $page->children()->listed() ?>

or if you want to include drafts:

<?php $pastdeals = $page->childrenAndDrafts() ?>

Note that image is a native Kirby method. If you name a field like that, you have to go via the content object:

<?php if ( $image = $pastdeal->content()->image()->toFile() ) : ?>
    <img src="<?= $image->url() ?>">
<?php endif; ?>

Never forget the if statement when dealing with objects.

Wow. Worked like a charm! Thank you so much!