$article = new Article;
// This was throwing an exception because article is not loaded
$images = $article->getImages();
// New function to retrieve a field by its name
$yearField = $article->fieldByName('year');
// Check if a field has a value assigned an retrieve it
if ($yearField->hasValue() && $yearField->value() === '2018')
{
echo 'This article is from year 2018';
}
// Use a function to retrieve only articles of category 23
$categoryArticles = $articles->filter(
function ($article)
{
return 23 === (int) $article->get('catid');
}
);