I feel like I should be able to do this by now, seeing as I already do things like if bla bla toFile() etc… but I can’t seem to get my head around this one.
My home controller is as follow:
<?php
return function ($site) {
$limit = 5;
$list = page('blog')->children()->listed()->sortBy('itemDate', 'desc', 'itemTime', 'desc')->limit(5);
if ($site->find('photography')) {
$album = page('photography')->children()->listed()->sortBy('itemDate', 'desc', 'itemTime', 'desc')->limit(5);
$list = $list->add($album)->sortBy('itemDate', 'desc', 'itemTime', 'desc');
}
return [
'list' => $list
];
};
I have a field called cover which is obviously an image field and on other pages I will use the if toFile method, but this one I only want to get children that have a cover image.
Is it something like
$list = page(‘blog’)->children()->listed()->sortBy(‘itemDate’, ‘desc’, ‘itemTime’, ‘desc’)->hasImages()->limit(5);
(this doesn’t work btw)