Всем привет, ребята подскажите как мне правильно вывести 5 новостей из базы.. пример в скриншоте
model
public static function getFiveArticlesForSportPit()
{
return self::find()
->where(['status' => self::STATUS_ON])
->asArray()
->limit('5')
->orderBy(['id' => SORT_DESC])
->all();
}
view
<div class="news">
<?php foreach ($fiveArticles as $article) : ?>
<div class="new-long">
<div class="new-long-img">
<?= Html::img('/web/uploads/articles/' . Articles::getImageTitle($article['img_id']), ['width' => '320', 'height' => '240']) ?>
</div>
<div class="new-long-title">
<?= $article['title'] ?>
</div>
<div class="new-long-text">
<?= $article['text'] ?>
</div>
<div class="new-long-date">
<?= $article['created_at'] ?>
</div>
<div class="new-long-readmore">
</div>
</div>
<div class="new-short">
<div class="new-short-img">
<?= Html::img('/web/uploads/articles/' . Articles::getImageTitle($article['img_id']), ['width' => '320', 'height' => '240']) ?>
</div>
<div class="new-short-title">
<?= $article['title'] ?>
</div>
<div class="new-short-description">
<?= $article['text'] ?>
</div>
<div class="new-short-date">
<?= $article['created_at'] ?>
</div>
<div class="readmore">
</div>
</div>
<?php endforeach; ?>